一、File 类
1、一个File类对象,表示了磁盘上的文件或目录
2、File类提供了与平台无关的方法对磁盘上文件或目录进行操作
3、File类直接处理文件和文件系统
4、File类没有指定信息怎样从文件读取或者向文件存储
二、File 创建文件
public class FileTest1 { public static void main(String[] args) throws IOException { File file = new File("d:/test.txt"); System.out.println(file.createNewFile()); } }
显示
true
说明创建成功。
三、在文件夹下创建文件
public static void main(String[] args) throws IOException { File file = new File("c:/abc"); File file2 = new File(file, "hello.txt"); System.out.println(file2.createNewFile()); }
将在abc文件夹下创建hello.txt文件
原文:https://www.cnblogs.com/linlf03/p/10853950.html