美文网首页Java
RandomAccessFile(断点)

RandomAccessFile(断点)

作者: Xr丶_c967 | 来源:发表于2017-12-04 10:31 被阅读0次

    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(断点)

        本文链接:https://www.haomeiwen.com/subject/nuifpxtx.html