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
|
URI uri = null;
try {
uri = new URI("http://www.docx2doc.com/convert/convert-file/convert-html");
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(uri);
MultipartEntity reqEntity = new MultipartEntity(
HttpMultipartMode.BROWSER_COMPATIBLE);
try{
reqEntity.addPart("email",new StringBody(""));
reqEntity.addPart("input_type",new StringBody("txt"));
reqEntity.addPart("output_type",new StringBody("html"));
reqEntity.addPart("script",new StringBody("convert"));
FileBody bin = new FileBody(
new File("ad.txt"),"text/plain");
reqEntity.addPart("input_file", bin);
httppost.setEntity(reqEntity);
System.out.println("executing request " + httppost.getRequestLine());
HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
String page = EntityUtils.toString(resEntity);
System.out.println("PAGE :" + page);
}
} catch (Exception e){
} |
Partager