Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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();
    }


Le import java.io.IoException; Functions Problem Set/src PS3 Functions java 2 import java. io file. Files 3 import java.nio.file. Paths; import java.util.ArrayList; public class FilesLecture3 5 points static void Q1 (string filename, Array List

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?

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote