我有一个服务器链接,我需要阅读pdf内容。我使用了下面的代码,但它给出了其他格式的结果。如何从服务器读取pdf内容并保存在文件中?
public String readPDF() throws Exception
{
BufferedReader in = null;
String page = "";
try {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI("http://14.140.41.194/monali/i.pdf"));
HttpResponse response = client.execute(request);
in = new BufferedReader
(new InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
sb.append(line + NL);
}
in.close();
page = sb.toString();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException