I am having a problem in this program....can anybody help me create a BufferedReader out of this maze problem...then i have to create a text document entitled with maze.txt...
well here is my program
import java.io.*;
import java.util.*;
public class Amazing{
public static void main(String[]args){
Scanner console=new Scanner(System.in);
FileWriter fw;
BufferedWriter bw;
int r,c;
try{
fw=new FileWriter("maze.txt",true);
bw=new BufferedWriter(fw);
String str[][]={{"","1","2","3","4","5","6","7","8","9","10"},
{"1","{}","{}","{}","{}","{}","{}","{}","{}","{}","{}"},
{"2","<>","{}","<>","<>","<>","<>","<>","<>","<>","<>"},
{"3","<>","<>","{}","<>","<>","<>","<>","<>","<>","<>"},
{"4","<>","<>","<>","{}","<>","<>","<>","<>","<>","<>"},
{"5","<>","<>","{}","<>","<>","<>","<>","<>","<>","<>"},
{"6","<>","<>","{}","{}","{}","<>","<>","<>","<>","<>"},
{"7","<>","<>","<>","<>","{}","<>","<>","<>","<>","<>"},
{"8","<>","<>","{}","{}","{}","<>","<>","<>","<>","<>"},
{"9","<>","<>","{}","{}","{}","{}","{}","{}","<>","<>"},
{"10","<>","<>","<>","<>","<>","<>","<>","[]","<>","<>"}};
bw.write("\n{}=Open, <>=Close, []=Exit");
for(int i=10;i>=0;i--){
bw.write("\n");
if(i==0){
bw.write("\n");
}
for(int j=0;j<=10;j++){
bw.write(str[i][j]);
}
}
bw.write("\n\n"+" ");
do{
System.out.print("\n\n Enter the position:");
r=console.nextInt();
c=console.nextInt();
}while(c==0||r==0);
System.out.println("\n\n Sample Run:");
System.out.print("\n\n\n"+" Positions"+" Remarks");
System.out.print("\n "+r+" "+c+" Start");
bw.write("\n\n Sample Run:");
bw.write("\n\n\n"+" Positions"+" Remarks");
bw.write("\n "+r+" "+c+" Start");
while(str[r][c]!="[]"){
if(c!=1){
if(str[r+1][c-1].equals("{}")){
r=r+1;
c=c-1;
System.out.print("\n "+r+" "+c+" Open");
bw.write("\n "+r+" "+c+" Open");
}
else{
System.out.print("\n "+(r+1)+" "+(c-1)+" Backtrack");
bw.write("\n "+(r+1)+" "+(c-1)+" Backtrack");
}
if(str[r][c-1].equals("{}") && r==1){
c=c-1;
System.out.print("\n "+r+" "+c+" Open");
bw.write("\n "+r+" "+c+" Open");
}
else{
System.out.print("\n "+r+" "+(c+1)+" Backtrack");
bw.write("\n "+r+" "+(c+1)+" Backtrack");
}
}
if(str[r+1][c].equals("{}")){
r=r+1;
System.out.println("\n "+r+" "+c+" Open");
bw.write("\n "+r+" "+c+" Open");
}
else{
System.out.print("\n "+(r+1)+" "+c+" Backtrack");
bw.write("\n "+(r+1)+" "+c+" Backtrack");
}
if(c!=10){
if(str[r+1][c+1].equals("{}")){
r=r+1;
c=c+1;
System.out.println("\n "+r+" "+c+" Open");
bw.write("\n "+r+" "+c+" Open");
}
else{
System.out.println("\n "+(r+1)+" "+(c+1)+" Backtrack");
bw.write("\n "+(r+1)+" "+(c+1)+" Backtrack");
}
if(str[r][c+1].equals("{}")&& r!=1){
c=c+1;
System.out.println("\n "+r+" "+c+" Open");
bw.write("\n "+r+" "+c+" Open");
}
else{
System.out.println("\n "+r+" "+(c-1)+" Backtrack");
bw.write("\n "+r+" "+(c-1)+" Backtrack");
}
}
if(str[r+1][c].equals("[]")){
r=r+1;
System.out.println("\n "+r+" "+c+" Exit");
bw.write("\n "+r+" "+c+" Exit");
}
}
System.out.println("\n\n\n Congratulations!!!");
bw.write("\n\n\n Congratulations!!!");
bw.close();
}
catch(IOException e){
System.out.println(e);
}
}
}