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();
}