我正在编写一个程序,它应该从选定的目录中选择 .txt 文件并使用 Acrobat Distiller 打印它们。目前,我可以选择并打开所有文件,但是我只打印了第一个文件并且出现了这个错误:System.out.println("COMPLETED") whitout 完成任何其他打印输出。
import java.io.File;
import java.io.IOException;
public class acrobat {
public static void main(String[] args) {
File foldertotalcountletters = new File("C:\\Users\\JayRaj\\workspace\\auto\\proof\\US\\letter\\07-01-2013");
File[] listOfFilestotalcountletters = foldertotalcountletters.listFiles();
String totalcountletters;
try{
for (int itotalcount = 0; itotalcount < listOfFilestotalcountletters.length; itotalcount++) {
if (listOfFilestotalcountletters[itotalcount].isFile()) {
totalcountletters = listOfFilestotalcountletters[itotalcount].getName();
System.out.println(totalcountletters);
Runtime runTime = Runtime.getRuntime();
Process process = runTime.exec("acrodist");
}
}
} catch (Exception e25) {
e25.printStackTrace();
}
}
}
这是更详细的错误内容。
Proof_US_30189650_06-29-13_mail_RecordCount_56.txt.txt
java.io.IOException: Cannot run program "acrodist.exe": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at acrobat.main(acrobat.java:24)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 5 more
我不知道该怎么做才能打印出所有选定的文件。