The error I am getting:
java.io.FileNotFoundException: /Users/coryallen/Desktop/input.txt (Operation not permitted)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112)
at java.base/java.io.FileReader.<init>(FileReader.java:60)
at Main.main(Main.java:41)
Here is my code
List<String> fileContents = new ArrayList<>();
try {
FileReader fReader = new FileReader(fileName);
BufferedReader fBuff = new BufferedReader(fReader);
while((fBuff.readLine()).contains("name")) {
System.out.println(fBuff.readLine());
}
} catch (Exception e) {
e.printStackTrace();
}
I tried a few different methods for reading this file and I cannot figure out why this is happening. The extensions I have used are .rtf and .txt, thinking maybe it was an issue with the file itself. The file just contains the following:
name John
weapon Sword