在PDFRender打开后,java无法删除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();
我的代码不起作用,它没有关闭文件
我的程序运行后无法删除该文件,它说JavaSE二进制平台已打开该文件
如何关闭由PDFRenderer打开的文件
# 1 楼答案
从第一行和第三行中删除额外的“)”
希望它能帮助你