File类概述和构造方法:
1、File类概述:
File:文件和目录路径名的抽象表达形式;确切的说File更应该叫做一个路径;
2、构造方法:
* File(String pathname):根据一个路径得到File对象
* File(String parent, String child):根据一个目录和一个子文件/目录得到File对象
* File(File parent, String child):根据一个父File对象和一个子文件/目录得到File对象
3、示例代码如下:
//* File(String pathname):根据一个路径得到File对象
File file = new File ("F:\\新建文件夹\\aaa.txt");
System.out.println(file.exists());
//* File(String parent, String child):根据一个目录和一个子文件/目录得到File对象
String parent = "F:\\新建文件夹";
String child = "aaa.txt";
File file1 = new File(parent,child);
System.out.println(file1.exists());
//* File(File parent, String child):根据一个父File对象和一个子文件/目录得到File对象 *
File parent1 = new File("F:\\新建文件夹");
String child1 = "aaa.txt";
File file2 = new File(parent1,child1);
System.out.println(file2.exists());