我正在尝试读取一个简单的文件,然后是用户应该选择的文件。我不断收到以下错误:
Readzilla.java:37:找不到符号
符号:方法 FileReader(java.lang.String)
位置:类 java.io.BufferedReader
line = read.FileReader(newDoc);
这是代码。
import java.io.*;
public class Readzilla
{
public static void main(String[] args) throws IOException
{
String line;
BufferedReader read;
// BufferedReader "read" reads the file
BufferedReader in;
// BufferedReader "in" reads the input sent by the user
String loop;
// "loop" decides whether another document should be read
in = new BufferedReader(new InputStreamReader(System.in));
read = new BufferedReader(new FileReader("message.txt"));
line = read.readLine();
while(line != null)
{
System.out.println(line);
line = read.readLine();
}
// read another document
System.out.println("Would you like to read another document? (Y/N)");
loop = in.readLine();
loop = loop.toUpperCase();
if (loop == "Y")
{
do
{
System.out.println("What file (.txt) would you like to read?");
String newDoc = in.readLine();
// newDoc reads a text file of the user's choosing
line = read.FileReader(newDoc);
// ^ This line constantly gives errors
System.out.println("Reading...");
line = read.readLine();
while(line != null)
{
System.out.println(line);
line = read.readLine();
}
// read another document
System.out.println("Would you like to read another document? (Y/N)");
loop = in.readLine();
}
while (loop == "Y");
}
else
{
System.out.println("Closing Program...");
}
}
}