RandomAccessFile(断点)

RandomAccessFile  raf=null;

try {

raf=new  RandomAccessFile("E:/test.txt", "rw");

raf.writeChars("大哥你a家有400斤鸭吗?送到巴拿马");

System.out.println(raf.getFilePointer());//32

raf.seek(4);

System.out.println(raf.getFilePointer());//4

char c=raf.readChar();

System.out.println(c);//你

System.out.println(raf.getFilePointer());//6

raf.writeInt(10);

System.out.println(raf.getFilePointer());//10

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

你可能感兴趣的:(RandomAccessFile(断点))