private void runProcess() throws Exception
{
try
{
Runtime rt = Runtime.getRuntime();
Process process = rt.exec("cmd /c cp C:\\work\\dev\\test.txt C:\\work\\dev\\test1.txt");
BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null;
while ((line = input.readLine()) != null)
{
System.out.println(line);
}
int exitVal = process.waitFor();
if (exitVal != 0)
{
input = new BufferedReader(new InputStreamReader(process.getErrorStream()));
line = null;
while ((line = input.readLine()) != null)
{
System.out.println(line);
}
}
}
catch (Exception e)
{
System.out.println(e.toString());
e.printStackTrace();
}
}
No comments:
Post a Comment