Hi,
I used the following codes and i keep getting the funny outputs below, how do i rectify the problem?? i tried to initialise variable 'ch' to different values but still fails. Any advise???
try {
BufferedReader in = new BufferedReader(new FileReader("file"));
PrintWriter pw = new PrintWriter(new FileWriter("modifiedfile"));//
int ch;
char c;
ch = in.read();
c = (char) ch;
while (ch != -1) {
String str = ""+c;
ch = in.read();
c = (char) ch;
System.out.print(c);
pw.write(ch);
}
in.close();
pw.close();
}catch (IOException ioe) {
System.out.println("There was a problem reading the file");
}
}
Output
======
ame : James
Date : 6th July 2004?
Regards
Shilong
I used the following codes and i keep getting the funny outputs below, how do i rectify the problem?? i tried to initialise variable 'ch' to different values but still fails. Any advise???
try {
BufferedReader in = new BufferedReader(new FileReader("file"));
PrintWriter pw = new PrintWriter(new FileWriter("modifiedfile"));//
int ch;
char c;
ch = in.read();
c = (char) ch;
while (ch != -1) {
String str = ""+c;
ch = in.read();
c = (char) ch;
System.out.print(c);
pw.write(ch);
}
in.close();
pw.close();
}catch (IOException ioe) {
System.out.println("There was a problem reading the file");
}
}
Output
======
ame : James
Date : 6th July 2004?
Regards
Shilong