In my java program I need to read the contents of file line by line using java.I tried the following code but I am getting this error
import acm.program.*;
import acm.util.*;
import java.io.*;
import java.util.*;
public class ReadFile extends ConsoleProgram{
private BufferedReader openFileReader(String Prompt){
BufferedReader rd =null;
while(rd==null){
String name=readLine(Prompt);
try{
rd=new BufferedReader(new FileReader(name));
}catch(IOException ex){
println("cannot open");
}
}
return rd;
}
public void run(){
BufferedReader rd = OpenFileReader('File');
try{
while(true){
String line=rd.readLine();
if(line==null){
break;
}
rd.close();
catch(IOException ex){
throw new ErrorException(ex);
}
}
}
}
}
I am getting error in this line
BufferedReader rd = OpenFileReader('File');
The error I am getting is "Invalid character constant". How should I resolve this?