Anyone know how i can open a file for RandomAccess and increment the file pointer from character to character? I open the file in "r" read mode but im not sure if this is the right way to position the file pointer.
It makes sense since each character should be two bytes even though they are encoded in UTF-8 since they fall within the ASCII range. But all i keep getting is ? marks![]()
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"); while(true){ System.out.println(raf.readChar()); raf.seek(counter += 2); } }catch(IOException e){} } }




Reply With Quote