java.io.RandomAccessFile

 用途:文件的随机读写

定义:public clasee RandomAccessFile extends Object implement DataInput,DataOutput

构造涵数:

1、public RandomAccessFile(File file,String mode).

    (1)file:一个文件对象

    (2)读写模式  r=只读

                                 w=只写

                                rw=可读写

                                rws=

                                rwd=

2.   public RandomAccessFile(String fileName,String mode).

    (1) String name:要读写的文件名

 

常用方法

1.public void seek(long pos) throws IOException

    (1)功能:移动文件指针到pos指定的位置

2.public long getFilePointer() throws IOException

    功能:获取文件指针的位置,是相对于文件起始位置的偏移量,以字节为单位。

3.public final String readLine() throws IOException

    返回该文件下一行的文本,如文件已经结否,则返回null.

文件指针遵循的规律:

1、新建文件时,位于文件的开头。

2、读写操作后,后移到读写的字节数。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值