从java执行一些命令行

时间:2016-07-21 20:23:51

标签: java command-line

我想从java代码中执行这几行,但我不知道如何。

cd C:\\apps\\dcm4che-2.0.28\\dcm4che-tool\\dcm4che-tool-txt2dcmsr\\src\\bin 

txt2dcmsr.bat -c C:\\apps\\dcm4che-2.0.28\\dcm4che-tool\\dcm4che-tool-txt2dcmsr\\src\\etc\\txt2dcmsr.cfg C:\\Users\\intidhar\\Desktop\\input\\tst.txt \"C:\\Users\\intidhar\\Desktop\\output\\tst.dcm

我编写了这些java代码行,但它不起作用:

try { 
    Runtime runtime = Runtime.getRuntime();
    runtime.exec("C:\\apps\\dcm4che-2.0.28\\dcm4che-tool\\dcm4che-tool-txt2dcmsr\\src\\bin\\txt2dcmsr.bat -c \"C:\\apps\\dcm4che-2.0.28\\dcm4che-tool\\dcm4che-tool-txt2dcmsr\\src\\etc\\txt2dcmsr.cfg\" \"C:\\Users\\intidhar\\Desktop\\input\\tst.txt\" \"C:\\Users\\intidhar\\Desktop\\output\\tst.dcm\"");
    } catch (IOException e) {
     e.printStackTrace();
    }

0 个答案:

没有答案