RandomAccessFile类主要方法和构造函数.txt

RandomAccessFile类具备了文件操作的功能。(重要)
构造函数
RandomAccessFile(File file,String mode)
RandomAccessFile)String name,String mode)
参数说明
file:指定的文件对象
Mode:指定的操作模式(r为读模式,rw为读写模式)
Name:指定的文件名
RandomAccessFile类的主要方法

FileDescriptor getFD() //获取文件的描述
long getFilePointer() //获取文件指针的位置
long length() //获取文件的长度
int read() //从文件中读取一个字节
int read(byte[] b) //从文件中读取b.length个字节的数据并保存到数组b中
int read(byte[] b,int off,int len) //从文件中读取len个字节的数据并保存到数组b的指定位置中
boolean readBoolean() //从文件中读取一个boolean值
byte readbyte() //从文件读取一个字节
char readChar() //从文件读取一个字符
double readDouble() //从文件中读取一个double值
float readFloat() //从文件中读取一float值
void readFully(byte[] b) //从文件中的当前指针位置开始读取b.length个字节的数据到数组b中
void readFully(byte[] b,int off,int lne) //从文件中的当前指针位置开始读取len个字节的数据到
      //数组b的数组指定位置中
int readInt() //从文件中读取一个int值
String readLine() //从文件中读取一个字符串
long readLong() //从文件中读取一个long值
short readShort() //从文件中读取一个short值
int readUnsignedByte() //从文件中读取一个无符号的八位数值
int readUnsignedShort() //从文件中读取一个无符号的十六位数值
String readUTF() //从文件中读取一个字符串
void seek(long pos) //指定文件指针在文件中的位置
void setLength(long newLength) //设置文件的长度
int skipBytes(int n) //在文件中跳过指定的字节数
void write(byte[] b) //向文件中写入一个字节数组
void write(byte[] b,int off,int len) //向文件中写入数组b中从off位置开始长度为len的字节数据
void write(int b) //向文件中写入一个int值
void writeBoolean(boolean v) //向文件中写入一个boolean值
void writeByte(int v) //向文件中写入一个字节
void writeByte(String s) //向文件中写入一个字符串
void writeChar(int v) //向文件中写入一个字符
void writeChars(String s) //向文件中写入一个作为字符数据的字符串
void writeDouble(double v) //向文件中写入一个double值
void writeFloat(float v) //向文件中写入一个float值
void writeInt(int v) //向文件中写入一个int值
void writeLong(long v) //向文件中写入一个long值
void writeShort(int v) //向文件中写入一个短型int值
void writeUTF(String str) //向文件中写入一个UTF字符串

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值