这是我的代码,我对堆栈很陌生,不知道如何实现它们,尤其是使用缓冲阅读器。我不知道如何实现编程新手的堆栈代码。我必须编写一个程序来反转从我的 txt 文件中读取的方向并将它们打印出来。
try
{
BufferedReader in = new BufferedReader(new FileReader("GoingThere.txt"));
String line = in.readLine();
while(line != null)
{
line.replace("West","East");
line.replace("East","West");
line.replace("North", "South");
line.replace("South", "North");
line = in.readLine();
}
}
catch(FileNotFoundException e)
{
System.out.println("File Not Found");
}
catch(IOException e)
{
System.out.println("IO Exception Found.");
}