ObjectInputStream 类的 readUnsignedByte() 方法读取一个无符号的 8 位字节。
用法
public int readUnsignedByte() throws IOException
参数
没有传递参数。
返回
读取的 8 位字节。
抛出
IOException
例子1
import java.io.*;
public class ObjectInputStreamreadunsignedByteExample1 {
public static void main(String[] args) {
short b = 32767;
try {
FileOutputStream outstream = new FileOutputStream("file1.txt");
ObjectOutputStream objoutstream = new ObjectOutputStream(outstream);
objoutstream.writeByte(b);
objoutstream.flush();
ObjectInputStream objinstream = new ObjectInputStream(new FileInputStream("file1.txt"));
// read and print the using readUnsignedByte
System.out.println(" byte value:" + objinstream.readUnsignedByte());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
输出:
byte value:255
例子2
import java.io.*;
public class ObjectInputStreamreadunsignedByteExample2
{
public static void main(String[] args) throws IOException
{
FileOutputStream outstream = new FileOutputStream("file1.txt");
ObjectOutputStream objoutStream = new ObjectOutputStream(outstream);
ObjectInputStream objinStream = new ObjectInputStream(new FileInputStream("file1.txt"));
objoutStream.writeByte(121212);
objoutStream.flush();
System.out.println("readUnsignedShort():" + objinStream.readUnsignedByte());
}
}
输出:
readUnsignedShort():124
相关用法
- Java ObjectInputStream readUnsignedByte()用法及代码示例
- Java ObjectInputStream readUnsignedShort()用法及代码示例
- Java ObjectInputStream readUnshared()用法及代码示例
- Java ObjectInputStream readUTF()用法及代码示例
- Java ObjectInputStream readDouble()用法及代码示例
- Java ObjectInputStream readFields()用法及代码示例
- Java ObjectInputStream readFully()用法及代码示例
- Java ObjectInputStream readInt()用法及代码示例
- Java ObjectInputStream read()用法及代码示例
- Java ObjectInputStream readField()用法及代码示例
- Java ObjectInputStream readShort()用法及代码示例
- Java ObjectInputStream readByte()用法及代码示例
- Java ObjectInputStream readLong()用法及代码示例
- Java ObjectInputStream readStreamHeader()用法及代码示例
- Java ObjectInputStream readObjectOverride()用法及代码示例
- Java ObjectInputStream readChar()用法及代码示例
- Java ObjectInputStream readObject()用法及代码示例
- Java ObjectInputStream readLine()用法及代码示例
- Java ObjectInputStream readBoolean()用法及代码示例
- Java ObjectInputStream readFloat()用法及代码示例
注:本文由纯净天空筛选整理自 Java ObjectInputStream readUnsingedByte() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。