1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
public static InputStream retrieve(String url) throws IOException{
HttpURLConnection uc = (HttpURLConnection) new URL(url).openConnection();
uc.setRequestProperty("Accept", "application/xml");
uc.setRequestProperty("Accept-Encoding", "gzip");
uc.setRequestMethod("GET");
if(uc.getResponseCode()!= 200){
return null;
}
return new BufferedInputStream(uc.getInputStream());
}
public static InputStream add(String url) throws IOException{
HttpURLConnection uc = (HttpURLConnection) new URL(url).openConnection();
uc.setRequestProperty("Accept", "application/xml");
uc.setRequestProperty("Accept-Encoding", "gzip");
uc.setRequestMethod("POST");
if(uc.getResponseCode()!= 200){
return null;
}
return new BufferedInputStream(uc.getInputStream());
}
public static InputStream edit(String url) throws IOException{
HttpURLConnection uc = (HttpURLConnection) new URL(url).openConnection();
uc.setRequestProperty("Accept", "application/xml");
uc.setRequestProperty("Accept-Encoding", "gzip");
uc.setRequestMethod("PUT");
if(uc.getResponseCode()!= 200){
return null;
}
return new BufferedInputStream(uc.getInputStream());
}
public static InputStream delete(String url) throws IOException{
HttpURLConnection uc = (HttpURLConnection) new URL(url).openConnection();
uc.setRequestProperty("Accept", "application/xml");
uc.setRequestProperty("Accept-Encoding", "gzip");
uc.setRequestMethod("DELETE");
if(uc.getResponseCode()!= 200){
return null;
}
return new BufferedInputStream(uc.getInputStream()); |
Partager