我需要在命令提示符下使用java執行命令。當我在提示符中鍵入命令並且tutorial.mallet文件相應地創建時,該命令正常工作。但是當我通過代碼完成時,沒有任何事情發生。在java中執行命令的正確方法是什麼
的命令是:
C:\mallet> bin\mallet import-dir --input E:\InputFilesForTopicModeling --output E:\Tutorial\tutorial.mallet --keep-sequence --remove-stopwords
這是我的代碼
try {
Runtime rt=Runtime.getRuntime();
rt.exec("cmd /c"+ "cd mallet");
String export=" bin\\mallet import-dir --input E:\\InputFilesForTopicModeling --output E:\\Tutorial\tutorial.mallet --keep-sequence --remove-stopwords";
rt.exec("cmd /c"+export);
} catch(Exception e) {
e.printStackTrace();
}
提示:縮進代碼。 – 2014-02-08 10:46:07