package com.day16.File;
import java.io.File;
/*
 * File(String pathname):根据一个路径得到File对象
 * File(String parent, String child):根据一个目录和一个子文件/目录得到File对象
 * File(File parent, String child):根据一个父File对象和一个子文件/目录得到File对象
 */
public class FileOne {
	    public static void main(String[] args) {
		      info();
		      fun();
		      File parent=new File("E:\\师兄师姐资料");
		      String child="三方.pdf";
		      File file=new File(parent, child);
		      System.out.println(file.exists());//true
	    }
	    private static void fun() {
		      String parent="E:\\师兄师姐资料";//父目录
		      String child="三方.pdf";//子目录
		      File file=new File(parent,child);
		      System.out.println(file.exists());//true
	    }
	    private static void info() {
		      File file=new File("E:\\师兄师姐资料\\三方.pdf");
		      System.out.println(file.exists());//true
		
		      File file1=new File("zhujialei.txt");
		      System.out.println(file1.exists());//true
	    }
}
原文:https://www.cnblogs.com/zhujialei123/p/9053617.html