将文件从一个目录移动到另一个目录
import java.io.File; import java.io.IOException; //来自 n o w j a v a . c o m public class Main { public static void main(String[] arg) throws IOException { File f = new File("logs\\myfile.txt"); if (f.renameTo(new File("savedlogs\\myfile.txt"))) System.out.println("File moved."); else System.out.println("File not moved."); } }