Runtime rt = Runtime.getRuntime();
int rc = -1; try
{
Process proc = rt.exec(cmd);
int bufSize = 10240;
BufferedInputStream bis =
new BufferedInputStream(proc.getInputStream(), bufSize);
int len;
byte buffer[] = new byte[bufSize]; // Echo back what the program spit out
while ((len = bis.read(buffer, 0, bufSize)) != -1)
System.out.write(buffer, 0, len); rc = proc.waitFor();
}
catch (Exception e)
{
e.printStackTrace();
rc = -1;
return false;
}
finally
{
System.out.write(rc);
return true;
}
如果我的命令当中包含的数据库口令是错误的,不能象我直接在CMD窗口中可以得到的提示进行重新输入,这个进程好象始终是处于等待状态,我该怎么解决?多谢指点。
int rc = -1; try
{
Process proc = rt.exec(cmd);
int bufSize = 10240;
BufferedInputStream bis =
new BufferedInputStream(proc.getInputStream(), bufSize);
int len;
byte buffer[] = new byte[bufSize]; // Echo back what the program spit out
while ((len = bis.read(buffer, 0, bufSize)) != -1)
System.out.write(buffer, 0, len); rc = proc.waitFor();
}
catch (Exception e)
{
e.printStackTrace();
rc = -1;
return false;
}
finally
{
System.out.write(rc);
return true;
}
如果我的命令当中包含的数据库口令是错误的,不能象我直接在CMD窗口中可以得到的提示进行重新输入,这个进程好象始终是处于等待状态,我该怎么解决?多谢指点。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货