参考
从D盘copy一份文件到E盘。
public static void main(String[] args) {
try {
String cmdStr = "cmd /c copy d:\\test.txt e:\\" ;
Runtime.getRuntime().exec(cmdStr);
}catch(Exception e){
e.printStackTrace();
}
}
注:这里d盘下的目录要用\\,若用d:/test.txt则会理解成同/c一样的命令,而找不到文件路径;故这里可以用file.getAbsolutePath();
system.getruntime().execute可以执行DOS命令