Noobish 질문 확실하지만 명령 프롬프트를 열고 디렉터리로 전환 한 다음 두 번째 명령을 실행하려고합니다.Java - 명령 프롬프트 열기, 두 개의 명령 실행
try {
// Execute command
String command = "cmd /c start cmd.exe";
Process child = Runtime.getRuntime().exec(command);
// Get output stream to write from it
OutputStream out = child.getOutputStream();
out.write("cd C:\Users\Me\Desktop\Reports\Scripts /r/n".getBytes());
out.flush();
out.write("for %f in (*.txt) do type "%f" >> Export.txt /r/n".getBytes());
out.close();
} catch (IOException e) {
}
내 무지 추측이 두 번째 명령의 "% f를" 제대로 작성해야하지만, 나는 그것을 할 방법을 잘 모르겠어요 자바에 대한 그래서 조금 알고 : 내가있어.
당신을 "% f"를'\ "% f \"로 작성하십시오. – Titus
Java (및 C 유래 구문이있는 다른 언어)에서 문자열 이스케이프에 대해 얼마나 알고 있습니까? – immibis
@ immibis : 누구의 제로. 많은 VBA를 일하면서 자바에 도전 해보십시오. – TechnoWolf