android 자체에서 현재 파일 실행하기를 하는 중입니다.
작성된 파일은 예를 들어서 test.py라는 파이썬으로 작성된 툴입니다.
현재 소스코드가
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class Test {
/**
* @param args
* @throws IOException
* @throws InterruptedException
*/
public static void main(String[] args) throws IOException,
InterruptedException {
// TODO Auto-generated method stub
Runtime rt = Runtime.getRuntime();
Process process = rt.exec(new String[] { "cmd.exe", "/c",
"c:\\Windows\\system32\\tasklist.exe" });
InputStream out = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(out));
String line;
System.out.println("asdasdas");
while ((line = reader.readLine()) != null) {
System.out.println("aaaa " + line);
}
}
}
라고 해서 tastlist.exe파일을 실행하는데까지는 성공을 하였습니다만,
제가 실행하고자 하는 파일은 파이썬으로 작성된 확장자가 .py로 된 것이라는 점입니다.
다른 외부 프로그램을 실행하기 위해서 어떻게 조치를 해야할지 궁금하여 이렇게 질문드립니다.
현재 test.py의 경로는 C:\Email\test.py의 경로에 넣어놨습니다.
어떻게 파일을 읽어서 print할 수 있을지 고수분들의 답변 부탁드립니다.
감사합니다.!





다른 pdf파을의 경우에는
public class ShowPDF { public static void main(String[] args) throws Exception { Process p = Runtime.getRuntime() .exec("rundll32 url.dll,FileProtocolHandler c:/pdf/mypdf.pdf"); p.waitFor(); System.out.println("Done."); } }