Java阅读文本项目

Java阅读文本项目,java,Java,大家好,我用java做了一个阅读文本文件的项目,但它不起作用,我希望你们能帮助我 package read_file; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Demo { public static void main(String[] args) { BufferedReader br= null; try{ br= new

大家好,我用java做了一个阅读文本文件的项目,但它不起作用,我希望你们能帮助我

package read_file;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Demo {


public static void main(String[] args) {
BufferedReader br= null;



try{
br= new BufferedReader (new FileReader("C:\\Users\\hp\\workspace\\MyFFFFProject"));


String line ; 

while ((line=br.readLine())!= null ) { 
    System.out.println(line);
}
}catch (IOException e){ 
e.printStackTrace();
}finally {
try{
    br.close();
}catch(IOException e){
    e.printStackTrace();
    }
}
}

}
在控制台中,此消息为我显示

java.io.FileNotFoundException: C:\Users\hp\workspace\MyFFFFProject (Access is denied)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at java.io.FileReader.<init>(FileReader.java:58)
at read_file.Demo.main(Demo.java:11)

Exception in thread "main" java.lang.NullPointerException
at read_file.Demo.main(Demo.java:21)
我要读取的文件是NotePad++,包含以下内容:-

this is my file content line 1 this is my file content line 2 this is my file content line 3 this is my file content line 4 this is my file content line 5 this is my file content line 6 this is my file content line 7
检查您的文件权限。您或运行该程序的用户似乎没有此特定文件的读取权限。
我有一个linux的盒子,并尝试了相同的代码,它的工作。我强制为自己设置了“无读取权限”,并出现了相同的错误。

异常显示访问被拒绝。。。该文件是否在其他应用程序(如记事本++)中打开?您可以使用Files.readLines并传递路径对象。是否确定MyFFFFProject是文件而不是文件夹?是否可以?没有理由让代码看起来像这样。欢迎使用java.io.File,其中每个异常都是FileNotFound,消息比这里的异常类型更重要。您检查过了吗?