contractstream是完整的pdf流,但是这样生成的pdf文件在写字板打开是pdf流,用pdfreader打开就是空白,啥都没有,但是pdf有大小。菜鸟求大神指教。。。。()
com.gargoylesoftware.htmlunit.WebResponse wrs = (com.gargoylesoftware.htmlunit.WebResponse)webClient.loadWebResponse(webRequest);
File file = new File("D://"+"ds.pdf");
FileOutputStream fop = new FileOutputStream(file,true);
String contratstream=wrs.getContentAsString();
fop.write(contratstream.getBytes());
fop.close();
后来这样写,直接pdf都打不开了。。。
com.gargoylesoftware.htmlunit.WebResponse wrs = (com.gargoylesoftware.htmlunit.WebResponse)webClient.loadWebResponse(webRequest);
File file = new File("D://"+"ds.pdf");
FileOutputStream fop = new FileOutputStream(file,true);
InputStream contratstream=wrs.getContentAsStream();
InputStreamReader inputStreamReader = new InputStreamReader(contratstream, "GBK");
BufferedReader reader = new BufferedReader(inputStreamReader);
String str=null;
String line;
while((line = reader.readLine())!=null){
str += line;
}
fop.write(str.getBytes());
fop.close();
求大神指教。。。