确定是否可以读取文件
import java.io.File; /**时 代 J a v a 公 众 号 - nowjava.com**/ public class Main { public static void main(String[] args) { String filePath = "C:/Folder/ReadText.txt"; File file = new File(filePath); if (file.canRead()) { System.out.println("File " + file.getPath() + " can be read"); } else { System.out.println("File " + file.getPath() + " can not be read"); } } }