java调用cmd命令并达到在CMD窗口执行的效果,但是执行后,只输出“你好”“1”,搞了很久都没结果 20
/****//***@authorHTL**/importjava.io.InputStreamReader;importjava.io.LineNumberReader...
/**
*
*/
/**
* @author HTL
*
*/
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.IOException;
public class service{
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO 自动生成的方法存根
System.out.println("你好");
String a="cmd.exe /c adb shell";
String b="cmd.exe /c cd /proc/uid_stat/10121";
String c="cmd.exe /c tcp_rcv ";
String d="cmd.exe /c tcp_snd";
Process process;
int i=1;
do {
if (i==1) process = Runtime.getRuntime().exec(a);
else if (i==2) process = Runtime.getRuntime().exec(b);
else if (i==3) process = Runtime.getRuntime().exec(c);
else process = Runtime.getRuntime().exec(d);
InputStreamReader ir=new InputStreamReader(process.getInputStream());
LineNumberReader input=new LineNumberReader(ir);
String line;
while((line=input.readLine())!=null)
System.out.println(line);
i++;
}while(i<=4);
System.out.println("5");
}
} 展开
*
*/
/**
* @author HTL
*
*/
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.IOException;
public class service{
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO 自动生成的方法存根
System.out.println("你好");
String a="cmd.exe /c adb shell";
String b="cmd.exe /c cd /proc/uid_stat/10121";
String c="cmd.exe /c tcp_rcv ";
String d="cmd.exe /c tcp_snd";
Process process;
int i=1;
do {
if (i==1) process = Runtime.getRuntime().exec(a);
else if (i==2) process = Runtime.getRuntime().exec(b);
else if (i==3) process = Runtime.getRuntime().exec(c);
else process = Runtime.getRuntime().exec(d);
InputStreamReader ir=new InputStreamReader(process.getInputStream());
LineNumberReader input=new LineNumberReader(ir);
String line;
while((line=input.readLine())!=null)
System.out.println(line);
i++;
}while(i<=4);
System.out.println("5");
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询