0

このトピックに関する別の質問を見ました。試してみましたが、まだうまくいきません

私のコード:

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 で開いたファイルを閉じるにはどうすればよいですか?

4

1 に答える 1

0

1 行目と 3 行目の余分な「)」を削除します。

File file = new File("C:\\Testing\\abc.pdf")); //last ')' one
ReadableByteChannel ch = Channels.newChannel(new FileInputStream(file)); //last ')' one

それがあなたを助けることを願っています。

于 2013-08-03T08:45:37.663 に答える