我有以下代码:
import.java.io.*;
public class BasheminParkingLot
{
public static void main(String[]args)throws Exception
{
Stack parkinglot = new Stack();
Stack alley= new Stack();
File f = new File("bashemin.in");
FileInputStream finstream = new FileInputStream(f);
InputStreamReader finreader = new InputStreamReader(finstream);
BufferReader finput = new BufferReader(finreader);
String line = finput.readLine();
String plate = "";
System.out.println();
System.out.println("The Bashemin Status");
System.out.println();
while(line!=null)
{
if(line.charAt(0)=='a')
{
plate = line.substring(1);
System.out.println ("car" + plate + " arrived and parked");
parkinglot.Push(plate);
}
}
}
}
我收到了错误:
BasheminParkingLot.java:13:错误:找不到符号 BufferReader finput = new BufferReader(finreader); ^
我想知道是否有人可以帮我调试这个?谢谢!
答案 0 :(得分:0)
这不应该是BufferReader
。它应该是BufferedReader
。
以下代码可以使用:
import java.io.*; class Stack { int x; void Push(String value) { // DO SOMETHING } } public class BasheminParkingLot { public static void main(String[]args)throws IOException { Stack parkinglot = new Stack(); Stack alley= new Stack(); File f = new File("bashemin.in"); FileInputStream finstream = new FileInputStream(f); InputStreamReader finreader = new InputStreamReader(finstream); BufferedReader finput = new BufferedReader(finreader); String line = finput.readLine(); String plate = ""; System.out.println(); System.out.println("The Bashemin Status"); System.out.println(); while(line!=null) { if(line.charAt(0)=='a') { plate = line.substring(1); System.out.println ("car" + plate + " arrived and parked"); parkinglot.Push(plate); } } } }