Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我正在使用pdfbox-app-2.0.0-RC3,但在PDF解析器中使用RndomAccessFile时仍然出现错误_Java_Pdfbox - Fatal编程技术网

Java 我正在使用pdfbox-app-2.0.0-RC3,但在PDF解析器中使用RndomAccessFile时仍然出现错误

Java 我正在使用pdfbox-app-2.0.0-RC3,但在PDF解析器中使用RndomAccessFile时仍然出现错误,java,pdfbox,Java,Pdfbox,-您可以通过以下链接查看示例: 错误 线程“main”java.lang.ClassCastException中的异常:java.io.RandomAccessFile无法转换为org.apache.pdfbox.io.RandomAccessRead 在aechaec.PDFManager.ToText(PDFManager.java:43) 在aechaec.aechaec.main(aechaec.java:25) Java结果:1 这是由安全特权引起的吗?因为我在mac上使用Netb

-您可以通过以下链接查看示例:

错误

线程“main”java.lang.ClassCastException中的异常:java.io.RandomAccessFile无法转换为org.apache.pdfbox.io.RandomAccessRead
在aechaec.PDFManager.ToText(PDFManager.java:43)
在aechaec.aechaec.main(aechaec.java:25)
Java结果:1


这是由安全特权引起的吗?因为我在mac上使用Netbeans?

有很多过时的例子,它们可能有效,也可能无效。请替换此代码

file = new File(filePath);
parser = new PDFParser(new RandomAccessFile(file,"r"));
parser.parse();
cosDoc = parser.getDocument();
pdfStripper = new PDFTextStripper();
pdDoc = new PDDocument(cosDoc);
此代码中的哪一项:

pdDoc = PDDocument.load(new File(filePath));
pdfStripper = new PDFTextStripper();

并更新到2.0的发行版。

有许多过时的示例,它们可能有效,也可能无效。请替换此代码

file = new File(filePath);
parser = new PDFParser(new RandomAccessFile(file,"r"));
parser.parse();
cosDoc = parser.getDocument();
pdfStripper = new PDFTextStripper();
pdDoc = new PDDocument(cosDoc);
此代码中的哪一项:

pdDoc = PDDocument.load(new File(filePath));
pdfStripper = new PDFTextStripper();

并更新到2.0的发行版。

我想知道您是否在使用Maven?我想知道您是否在使用Maven?好吧,已经有一段时间了,但是PDFParser构造函数想要一个RandomAccessRead实例,而不是RandomAccessFile。。如何得到它?任何想法都值得赞赏。要么按照答案中的内容去做,要么如果你真的想使用过时的
PDFParser
构造函数,那么就使用
RandomAccessFile
RandomAccessBufferedFileInputStream
构造函数。好吧,已经有一段时间了,但是PDFParser构造函数想要一个RandomAccessRead实例,而不是随机访问文件。。如何得到它?任何想法都值得赞赏。要么按照答案中的内容去做,要么如果你真的想使用过时的
PDFParser
构造函数,那么就使用
RandomAccessFile
RandomAccessBufferedFileInputStream
构造函数。