package com.mg.java.maven.day01; import java.io.File; import java.io.IOException; /** * 文件操作 * * @author admin * */ public class FileDemo { public static void main(String[] args) throws IOException { String path1 = "D:\Coding"; String path2 = "D:\FW"; String path3 = "D:\Coding\new.py"; File file1 = new File(path1); File file2 = new File(path2); File file3 = new File(path3); // 判断目录是否存在 System.out.println(file1.exists()); // 创建目录 // file2.mkdirs(); // 创建文件 file3.createNewFile(); // 判断是不是目录 System.out.println(file1.isDirectory()); } }