我試圖執行命令行來複制文件夾,但沒有任何反應。我從命令行嘗試了相同的命令,它工作正常。 代碼試圖在Java中使用xcopy來複制文件夾
Runtime rt = Runtime.getRuntime();
String line;
try {
Process pr = rt.exec("xcopy //E //I notts nots2");
InputStreamReader mInputStreamReader = new InputStreamReader(pr.getInputStream());
BufferedReader input = new BufferedReader(mInputStreamReader);
while ((line = input.readLine()) != null)
System.out.println(line);
} catch (IOException e) {
ted=ted+1;
}
你能告訴我們什麼被放入錯誤流嗎? –
另外,你應該做一些IOException。代碼寫入的方式是反模式。看[隱藏錯誤](https://en.wikipedia.org/wiki/Error_hiding)。順便說一句......誰是'ted'? –