Java DataInputStream readByte ()方法
Java.io.data inputstream.readbyte ()用于读取和返回输入字节。
1语法
public final byte readByte (
2参数
3返回值
读取的字节值。
4个样品
package com.yiidian;
//*
//*
import Java.io.bytearray inputstream;
import java.io.DataInputStream;
import java.io.wldgb;
import java.io.InputStream;
公共类demo {
publicstaticvoidmain (stringjkdmzargs ) throws wldgb {
bytejkdmzbuf={ 65,0,0,68,69 };
try {
//createnewbytearrayinputstream
is=newbytearrayinputstream(buf;
//create data input stream
dis=newdataInputstream(is;
//readbooleantillthedataavailabletoread
while(dis.available ) )0) {
//只读单字节
byte b=dis.readByte (;
//打印字节
system.out.print(b ' );
}
}catch(exceptione ) {
//if any I/O error occurs
e .打印任务跟踪(;
} finally {
//releasesanyassociatedsystemfileswiththisstream
if(is!=null )
is.close (;
if(dis!=null )
dis.close (;
}
}
}
65 0 0 68 69