我已经看到有关此主题的另一个问题。 我试过,但它仍然不是为我工作由PDFRenderer打开后无法删除pdf
我的代码:
File file = new File("C:\\Testing\\abc.pdf");
RandomAccessFile raf = new RandomAccessFile(file, "r");
ReadableByteChannel ch = Channels.newChannel(new FileInputStream(file));
FileChannel channel = raf.getChannel();
ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
PDFFile pdffile = new PDFFile(buf);
/* The rest code to convert pdf to image
* according to number of pages in pdf given above, which will not be provided here
*/
/* Closing file */
raf.close();
ch.close();
channel.close();
buf.clear();
我的代码不能正常工作,它没有关闭文件
我的程序后,我无法删除文件它跑了,它说Java SE Binary Platform已经打开了这个文件。
如何关闭由PDFRenderer打开的文件?
看看这里http://www.jarvana.com/jarvana/view/org/xhtmlrenderer/core-renderer/R8/core-renderer-R8-sources.jar!/org/xhtmlrenderer/simple/PDFRenderer。 java?format = ok – Algorithmist
关闭了'pdffile'? – gigadot
我希望我可以关闭它,但试图通过使用pdffile.close()来关闭它将导致“无法找到符号” 我读过你的链接Algorithmist,谢谢但我没有使用OutputStream,所以我没有知道他们是否对我有用 –