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

this is my code, but its is not able to read the input file, i have not idea why

ID: 3593236 • Letter: T

Question

this is my code, but its is not able to read the input file, i have not idea why.

public class Assignmentl public static void main(String[] args) BufferedReader br = null; tr FileInputstream fstream = new FileInputStream("assignment1.txt ") CircularLinkedList circularLinkedList- new CircularLinkedList); br new BufferedReader(new InputStreamReader(fstream)); StringBuilder sb = new StringBuilder(); string line = br.readLine(); int i = 1; while (null != line) { sb.append(line); sb.append (System.LineSeparator)); executeCommand(line,circularLinkedList); line = br . readLine(); catch (IOException e) { e.printStackTrace); Finally{ try if (br != null) { br.clos) catch (IOException e) { e.printstackTrace)

Explanation / Answer

The possible reasons for the error :

1. File itself not exists.

2. You may have provided the wrong relative path.

Note : If you simply launch the application from eclipse, the project directory will be the working directory, and you should in that case use "bin/assigment.txt" or "src/assigment.txt".

Try providing the absolute path in the format : "C:/Users/prati/Documents/sample/src/assignment.txt".

Here, "C:/Users/prati/Documents/sample" --> is the project directory and I have created a file under src folder.

Hope it helps.

Happy Learning