我正在尝试使用所有绝对路径的params执行pdf2html。同一命令通过命令提示符正常工作,但通过java给出错误。这是我正在使用的代码片段。
String command = pdf2html5ex_file_path +
" --decompose-ligature 1 --tounicode 1 \"" +
_curr_pdf_file.getAbsolutePath() +
"\" \"" +
_input_html_file_name +
"\" --dest-dir \"" +
removeEnd(_input_html_folder_path,"\\") +
"\" ";
String Perms = _curr_pdf_file.canRead()?"Readable":"Non-Readable";
Perms += ";"+ (_curr_pdf_file.canWrite()?"Writable":"Non-Writable");
Perms += ";"+ (_curr_pdf_file.canExecute()?"Executable":"Non-Executable");
System.out.println("Permissions : "+Perms);
System.out.println("Command: "+command);
Runtime runtime = Runtime.getRuntime();
// Execute command
Process process = runtime.exec(command);
异常消息:
Permissions : Readable;Writable;Executable
Command: E:\BackUpDisk\eTextCo\PDFBOX\WorkSpace\libs\pdf2htmlEX\pdf2htmlEX.exe --decompose-ligature 1 --tounicode 1 "E:\BackUpDisk\eTextCo\bookpad\Process\1\input\pdf\TM 11.pdf" "TM 11.html" --dest-dir "E:\BackUpDisk\eTextCo\bookpad\Process\1\input\html"
I/O Error: Couldn't open file 'E:\BackUpDisk\eTextCo\bookpad\Process\1\input\pdf\TM 11.pdf': File exists.
Error: Cannot read the file
Parsing completed for : TM 11.html
Unable to process record E:\BackUpDisk\eTextCo\bookpad\Process\1\input\pdf\TM 11.pdf
java.io.FileNotFoundException: E:\BackUpDisk\eTextCo\bookpad\Process\1\input\html\TM 11.html (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at org.jsoup.helper.DataUtil.load(DataUtil.java:37)
at org.jsoup.Jsoup.parse(Jsoup.java:88)
at Parser.pdf2html(Parser.java:213)
at Parser.main(Parser.java:33)
在上面的输出中,尝试打印将要执行的命令,它显示正确的文件路径为字符串,但第二行显示无法读取错误路径的文件(两个空格不存在)。
有人可以解释这里发生的事情吗?