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

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!