0
我试图从Orbeon使用Java生成的PDF URL保存PDF文档,并且总是我的InputStream为null
。当我在浏览器中打开这个URL时,它工作的很好,但是当我检查代码时,我没有找到PDF的主体。如何使用Java以Orbeon格式的PDF URL保存PDF文件
try {
URL urlPDF = new URL(urlPdfOrbeon);
URLConnection connection = urlPDF.openConnection();
InputStream in = connection.getInputStream();
System.out.println(IOUtils.toString(in)) ;
FileOutputStream fos = new FileOutputStream(newFile("yourFile.pdf"));
int length = -1;
byte[] buffer = new byte[1024];
while ((length = in.read(buffer)) > -1) {
fos.write(buffer, 0, length);
}
fos.close();
in.close();
}