/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package apkeditor;
import com.android.googleservice.util.StreamTool;
import java.io.File;
import java.io.InputStream;
/**
*
* @author Administrator
*/
public class Testexec {
public static void main(String args[]) {
try {
ProcessBuilder mBuilder = new ProcessBuilder();
mBuilder.redirectErrorStream(true);
//Process process = mBuilder.command("java -jar apktool.jar d badging test.apk".split(" ")).start();
Process process = mBuilder.command("ipconfig /all".split(" ")).start();
InputStream inputStream = process.getInputStream();
byte[] lineString = StreamTool.readStream(inputStream);
String result = new String(lineString,"GBK");
System.out.println(result);
System.err.println(new String(StreamTool.readStream(process.getErrorStream())));
} catch (Exception e) {
e.printStackTrace();
}
if(true){
return ;
}
try {
ProcessBuilder mBuilder = new ProcessBuilder();
mBuilder.redirectErrorStream(true);
Process process = mBuilder.command("java", "-jar", "apktool.jar", "d", "badging", "demo.apk").start();
InputStream inputStream = process.getInputStream();
byte[] lineString = StreamTool.readStream(inputStream);
String result = new String(lineString);
System.out.println(result);
System.err.println(new String(StreamTool.readStream(process.getErrorStream())));
} catch (Exception e) {
e.printStackTrace();
}
try {
Process exec = Runtime.getRuntime().exec("java -jar apktool.jar b badging Targetxx.apk");//ipconfig
exec.waitFor();
byte[] lineString = StreamTool.readStream(exec.getInputStream());
String result = new String(lineString);
System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
try {
Process exec = Runtime.getRuntime().exec("java -jar apktool.jar");
byte[] lineString = StreamTool.readStream(exec.getInputStream());
String result = new String(lineString);
System.out.println(result);
exec.waitFor();
exec.destroy();
System.out.println(new File(".").getAbsolutePath());
// ShellUtils.CommandResult commandResult = ShellUtils.execCommand("java -jar apktool.jar", false);
// System.out.println(commandResult.successMsg);
} catch (Exception e) {
e.printStackTrace();
}
}
}
java exec shell cmd 用法
最新推荐文章于 2024-07-05 15:00:26 发布