java io流在Linux上的Jboss EAP 6或Jboss 7.1.2上无法正常工作
我试图通过使用http客户端打开连接来读取pdf(位于)的内容,然后读取InputStream并写入OutStream。(是,此url只能通过我们的intarnet访问:)) 代码在上运行java io流在Linux上的Jboss EAP 6或Jboss 7.1.2上无法正常工作,java,jboss7.x,iostream,Java,Jboss7.x,Iostream,我试图通过使用http客户端打开连接来读取pdf(位于)的内容,然后读取InputStream并写入OutStream。(是,此url只能通过我们的intarnet访问:)) 代码在上运行 在我的windowsxp设备上作为独立的java客户端 在Jboss 7.1.2上,作为war文件的一部分在windowsxp上运行 在我们的linux机器上作为独立的java客户机 但此代码无法正确读取PDF 在Jboss 7.1.2上,作为war文件的一部分在linux上运行 在成功的情况下,当我从给定的
调试PDFServletHelperImpl:80 InputStream type=org.apache.http.conn。EofSensorInputStream@ab16d7 调试PDFServletHelperImpl:83 IOUtils字节数读取计数=970 信息PDFServletHelperImpl:85字节读取总数[970] 为了确保我本地的jboss和jboss上的linux框中加载的类没有什么不同,我打印了加载类的路径,在我们的webapp的linux和windows版本中,我看到类“org.apache.http.conn.EofSensorInputStream”从war文件中的httpclient-4.1.jar加载
在我运行jboss 7.1.2 Linux版本的代码时,有什么建议限制应用程序只能读取970字节而不是整个pdf流吗?可能是下载了其他东西。。970字节的内容是什么,比如说,如果你用IOUtils.toString或其他什么东西将其解析为字符串?这是PDF的前几个字节。我甚至硬编码了完全相同的url,它停止读取超过970字节的内容。我试过另一份文件也有同样的问题。
protected void streamPdfOut(InputStream in, HttpServletResponse resp)
throws IOException, FileNotFoundException {
ServletOutputStream out = resp.getOutputStream();
resp.reset();
resp.setContentType("application/pdf");
resp.setHeader("Content-disposition", "filename=List.pdf");
resp.setDateHeader("Expires", 0); //prevents caching at the proxy server
LOGGER.debug("InputStream type = "+ in);
//LOGGER.debug(" Loaded from :"+ in.getClass().getProtectionDomain().getCodeSource());
byte buff[] = IOUtils.toByteArray(in);
LOGGER.debug(" IOUtils Number of bytes read count ="+ buff.length);
out.write(buff, 0, buff.length);
LOGGER.info("bytesReadTotal [" + buff.length + "]");
// clean up
out.flush();
resp.flushBuffer();
out.close();
//close input stream and release any system resources.
in.close();
}