62,614
社区成员
发帖
与我相关
我的任务
分享
public static void runCmd()throws Exception
{
String command = "net user admin admin /add";
Process p = Runtime.getRuntime().exec(command);
printStream(p.getInputStream(),"getInputStream");
printStream(p.getErrorStream(),"getErrorStream");
}
public static void printStream(InputStream input,String title)throws Exception
{
System.out.println("----------------"+title+"----------------");
InputStreamReader isr = new InputStreamReader(input);
BufferedReader br = new BufferedReader(isr);
String str = null;
while( (str = br.readLine()) != null)
{
System.out.println(str);
}
br.close();
isr.close();
input.close();
}