Citation :
public static void put(String repDefaut, InputStream is, String nomFichier) throws IOException {
URL url = new URL(repDefaut + nomFichier);
HttpURLConnection connect =(HttpURLConnection)url.openConnection();
connect.setRequestMethod("PUT" );
connect.setDoOutput(true);
connect.setRequestProperty("ContentType", "text/xml" );
OutputStream os = connect.getOutputStream();
byte[] buf =new byte[1024];
int c;
while((c = is.read(buf)) > -1)
os.write(buf, 0, c);
LogManager.getInstance().log("Connecting to " + url.toString(),LogManager.INFORMATION);
connect.connect();
BufferedReader bis = new BufferedReader(new InputStreamReader(connect.getInputStream()));
String line;
while((line = bis.readLine()) !=null)
LogManager.getInstance().log(line,LogManager.INFORMATION);
os.close();
bis.close();
connect.disconnect();
}
|