Question: // I am trying to get text from .txt file (I ask for it using a readLine(); however it is giving me an error. Please

// I am trying to get text from .txt file (I ask for it using a readLine(); however it is giving me an error. Please have a look at my code, and can you tell me what the error is:

import stdlib.In; import stdlib.StdIn; import stdlib.StdOut;

public class StringSorter {

public static void main(String[] args) { StdOut.print("File to read in: "); String filename= StdIn.readLine(); In infile= new In(filename); String [] ourArray= infile.readAllStrings(); Insertion.sort(ourArray); for (int i= 0; i < ourArray.length; i++) { StdOut.println(ourArray[i]); } } }

//Best regards

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!