博客
关于我
RandomAccessFile 文本随机读写
阅读量:473 次
发布时间:2019-03-06

本文共 307 字,大约阅读时间需要 1 分钟。

java.io.RandomAccessFile是一个用于随机读写文件的类,适用于需要随机访问文件内容的场景。以下是该类的一些常用方法:

  • length()

    该方法返回文件的大小,以字节为单位。可以用来获取文件的总长度。

  • skipBytes(int n)

    该方法用于跳过文件中的n个字节,适用于需要快速定位文件特定位置的场景。

  • seek(long pos)

    该方法用于将文件游标移动到文件开头的pos位置。可以用来调整读写的位置。

  • getFilePointer()

    该方法返回当前文件游标的位置,方便用户获取当前读写的位置。

  • readLine()

    该方法从当前位置读取一行文本并返回字符串。可以用来逐行读取文件内容。

  • 转载地址:http://ldmbz.baihongyu.com/

    你可能感兴趣的文章
    NN&DL4.8 What does this have to do with the brain?
    查看>>
    nnU-Net 终极指南
    查看>>
    No 'Access-Control-Allow-Origin' header is present on the requested resource.
    查看>>
    NO 157 去掉禅道访问地址中的zentao
    查看>>
    no available service ‘default‘ found, please make sure registry config corre seata
    查看>>
    no connection could be made because the target machine actively refused it.问题解决
    查看>>
    No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
    查看>>
    No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
    查看>>
    No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
    查看>>
    No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
    查看>>
    No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
    查看>>
    No module named 'crispy_forms'等使用pycharm开发
    查看>>
    No module named cv2
    查看>>
    No module named tensorboard.main在安装tensorboardX的时候遇到的问题
    查看>>
    No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
    查看>>
    No new migrations found. Your system is up-to-date.
    查看>>
    No qualifying bean of type XXX found for dependency XXX.
    查看>>
    No resource identifier found for attribute 'srcCompat' in package的解决办法
    查看>>
    no session found for current thread
    查看>>
    No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
    查看>>