import java.lang.Runtime;
public class test
{ public static void main(String[] args)
{
Runtime r =Runtime.getRuntime();
Process p = null;
try{
p=r.exec("command.exe /c copy c:\\3001.txt c:\\3002.txt"); //1
p.waitFor(); //2
}
catch(Exception e)
{
e.printStackTrace(); }
}
}注:
1。调用DOS内部命令需要给出 COMMAND.EXE ;/C 是运行完DOS命令关闭DOS窗口
2。运行完COPY 后程序再继续执行
public class test
{ public static void main(String[] args)
{
Runtime r =Runtime.getRuntime();
Process p = null;
try{
p=r.exec("command.exe /c copy c:\\3001.txt c:\\3002.txt"); //1
p.waitFor(); //2
}
catch(Exception e)
{
e.printStackTrace(); }
}
}注:
1。调用DOS内部命令需要给出 COMMAND.EXE ;/C 是运行完DOS命令关闭DOS窗口
2。运行完COPY 后程序再继续执行
import java.lang.Runtime;
public class test
{ public static void main(String[] args)
{
try
{
Runtime.getRuntime().exec("cmd /c copy c:\\3001.txt c:\\3002.txt");//do will get it
}
catch(Exception e)
{
e.printStackTrace();
}
}}
p=r.exec("cmd.exe /c copy c:\\3001.txt c:\\3002.txt"); // cmd.exe win nt 下