java.io接口——dataInput和dataOutput

dataInput 共15个接口,2个读取方法(一个全读,一个读写指定位置),1个跳过的方法。10个读取基本字节的方法(boolean,byte,short,char,int,long,float,double,两个UnsignedByte,UnsignedShort,不带正负号的)1个读取一行,1个读取utf-8字符串

void readFully(byte b[]) throws IOException;

读取字节byte为待读取数据

void readFully(byte b[], int off, int len) throws IOException;

读取字节byte为待读取数据off为起始位置,len要读取的个数

int skipBytes(int n) throws IOException;

跳过n个字节。返回实际跳过的值

boolean readBoolean() throws IOException;

读取boolean(适用于写的接口writeBoolean)

byte readByte() throws IOException;

读取byte(适用于写的接口writeByte)

int readUnsignedByte() throws IOException;

读取接口返回0-255的值(适用于writerByte,参数0-255的时候)

short readShort() throws IOException;

读取short(适用于写的接口writeShort)

int readUnsignedShort() throws IOException;

同readUnsignedByte(适用于writerShort,参数0-65535的时候)

char readChar() throws IOException;

读取char

int readInt() throws IOException;

读取int

long readLong() throws IOException;

读取long

float readFloat() throws IOException;

读取float

double readDouble() throws IOException;

读取double

String readLine() throws IOException;

读取接下来的一行。结尾输出null

String readUTF() throws IOException;

读取utf-8的字符串

DataOutput包含14个方法1个输入int的8个低字节。2个写入byte[](全写,指定位置写),8个写基本字节的方法(boolean,byte,short,char,int,long,flout,double)3个写入字符串(一个bytes,chars,UTF)

void write(int b) throws IOException;

输入b的8个低节位,忽略24个高节位

void write(byte b[]) throws IOException;

指定位置插入 

void write(byte b[], int off, int len) throws IOException;

8个写基本类型 

void writeBoolean(boolean v) throws IOException;
void writeByte(int v) throws IOException;
void writeShort(int v) throws IOException;
void writeChar(int v) throws IOException;
void writeInt(int v) throws IOException;
void writeLong(long v) throws IOException;
void writeFloat(float v) throws IOException;
void writeDouble(double v) throws IOException;

3个写string类型 

void writeBytes(String s) throws IOException;
void writeChars(String s) throws IOException;
void writeUTF(String s) throws IOException;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值