Question: // function readLine(); doesn't work ??? it says String doesn't have this function why ?? import java.io.File; import java.io.FileReader; import java.util.Scanner; public class Test {
// function readLine(); doesn't work ??? it says String doesn't have this function why ??
import java.io.File;
import java.io.FileReader;
import java.util.Scanner;
public class Test {
public static void main ( String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter name of input file: ");
String fileName = input.nextLine();
String text = " ";
String line = fileName.readLine();
while ( line != null)
{
text += line ;
line = fileName.readLine();
}
System.out.print(text);
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
