Java building a string, creating, and writing files NEED Help. I am getting thes
ID: 3862277 • Letter: J
Question
Java building a string, creating, and writing files NEED Help. I am getting these errors and I know my code is wrong. I Need to get answer to this queestion but need to know how to do it with this style if my problem is not reading the file this is how i want to do that in this question.
try{
String filename = "src/test.txt";
for(String line : Files.readAllLines(Paths.get(filename))){
System.out.println(line);
}
} catch (IOException ex){
ex.printStackTrace();
}
Explanation / Answer
the exception says that you don't have acess to the file test.txt
i have created a same file in the src folder in eclipse and ran the code given by you in ques
try{
String filename = "src/test.txt";
for(String line : Files.readAllLines(Paths.get(filename))){
System.out.println(line);
}
} catch (IOException ex){
ex.printStackTrace();
}
and is running fine and even prinitng the file content
can you please share the whole code so as to resolve it?
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.