Here's another example. I have a file
that just contains my name "Brandon".
Im simply trapping a key from the console
and comparing it with the first character
within the file. "B". But when i press B the
it dosent match the first character in the file.
I get System.out.println(B + " Was pressed" +
" but it does not match " + ?);
Code:
import java.io.*;
public class X{
public static void main(String[] args){
try {
File f = new File("C:\\Java\\Brandon.txt");
int counter = 0;
RandomAccessFile raf = new RandomAccessFile(f, "r");
int i = System.in.read();
char c = raf.readChar();
char pressed = (char) i;
raf.seek(counter += 2);
System.out.println(pressed + " Was pressed" + " but it does not match " + c);
}catch(IOException e){}
}
}