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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started