package linux.test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class TestExe {
/**
* @param args
*/
public static void main(String[] args) {
try {
// String[] cmd = new String[] { "F:/task/aapt.exe", "l -a
// F:/task/update/10-6-23/apk/4003373.apk >
// F:/task/update/10-6-23/apk/4003373.txt" };
// Process process = Runtime.getRuntime().exec(cmd,null,new
// File("F:/task/"));
String command = "cmd /c start F:/task/task2010.6.24.bat";
// command ="F:/task/aapt.exe l -a
// F:/task/update/10-6-23/apk/4003373.apk >
// F:/task/update/10-6-23/apk/4003373.txt";
/*
* command = "/home/dingym/aapt d badging
* /home/dingym/YichaMarket.apk";
* System.out.println("------------start-------------");
* Runtime.getRuntime().exec(command);
* System.out.println("------------end---------------");
*/
/*
* BufferedReader r = new BufferedReader(new
* InputStreamReader(process .getErrorStream())); String l = null;
* while ((l = r.readLine()) != null) { System.out.println(l); }
*/
Runtime rt = Runtime.getRuntime();
System.out.println("------------start-test-------------");
String str[] = { "/bin/sh", "-c", "./aapt d badging YichaMarket.apk" };
System.out.println("------------end-test---------------");
Process pcs = rt.exec(str);
BufferedReader br = new BufferedReader(new InputStreamReader(pcs
.getInputStream()));
String line = new String();
while ((line = br.readLine()) != null) {
System.out.println(line);
}
try {
pcs.waitFor();
} catch (InterruptedException e) {
System.err.println("processes was interrupted");
}
br.close();
int ret = pcs.exitValue();
System.out.println(ret);
} catch (Exception e) {
e.printStackTrace();
}
}
}