Java ObjectInputStream readUnsignedShort()方法(带示例)

ObjectInputStream类readUnsignedShort()方法 (ObjectInputStream Class readUnsignedShort() method)

  • readUnsignedShort() method is available in java.io package.

    readUnsignedShort()方法在java.io包中可用。

  • readUnsignedShort() method is used to read 2 bytes (i.e. 16 bit) unsigned short of data from the ObjectInputStream.

    readUnsignedShort()方法用于从ObjectInputStream读取2个字节(即16位)的无符号缺少数据。

  • readUnsignedShort() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    readUnsignedShort()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • readUnsignedShort() method may throw an exception at the time of reading unsigned short.

    readUnsignedShort()方法在读取unsigned short时可能会引发异常。

    • IOException: This exception may throw when getting any input/output error while performing.IOException :在执行过程中遇到任何输入/输出错误时,可能引发此异常。
    • EOFException: This exception may throw when this stream is reached its end.EOFException :当此流到达末尾时,可能引发此异常。

Syntax:

句法:

    public int readUnsignedShort();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is int, it returns the unsigned short read.

方法的返回类型为int ,它返回无符号的短读取。

Example:

例:

// Java program to demonstrate the example 
// of int readUnsignedShort() method of 
// ObjectInputStream
import java.io.*;
public class ReadUnsingedShortOfOIS {
public static void main(String[] args) throws Exception {
// Instantiates ObjectOutputStream , ObjectInputStream 
// FileInputStream and FileOutputStream
FileOutputStream file_out_stm = new FileOutputStream("D:\\includehelp.txt");
ObjectOutputStream obj_out_stm = new ObjectOutputStream(file_out_stm);
FileInputStream file_in_stm = new FileInputStream("D:\\includehelp.txt");
ObjectInputStream obj_in_stm = new ObjectInputStream(file_in_stm);
// By using writeShort() method is to write
// short to the obj_out_stm stream
obj_out_stm.writeShort(-124);
obj_out_stm.writeShort(131);
obj_out_stm.writeShort(-182);
obj_out_stm.writeShort(154);
obj_out_stm.flush();
while (obj_in_stm.available() > 0) {
// By using readUnsingedShort() method is to read
// unsigned short from the obj_in_stm and returned
// as an integer
int val = (int) obj_in_stm.readUnsignedShort();
System.out.println("obj_in_stm.readUnsignedShort(): " + val);
}
// By using close() method is to 
// close all the streams 
file_in_stm.close();
file_out_stm.close();
obj_in_stm.close();
obj_out_stm.close();
}
}

Output

输出量

obj_in_stm.readUnsignedShort(): 65412
obj_in_stm.readUnsignedShort(): 131
obj_in_stm.readUnsignedShort(): 65354
obj_in_stm.readUnsignedShort(): 154

翻译自: https://www.includehelp.com/java/objectinputstream-readunsignedshort-method-with-example.aspx

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/542517.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

python中info的用法_Python pandas.DataFrame.info函数方法的使用

DataFrame.info(self, verboseNone, bufNone, max_colsNone, memory_usageNone, null_countsNone) [source] 打印DataFrame的简要摘要。 此方法显示有关DataFrame的信息,包括索引dtype和列dtype,非空值和内存使用情况。 参数:verbose &#x…

第四次作业 孙保平034 李路平029

用C编写一个学生成绩管理系统 1、可以实现以下功能&#xff1a; cout<<"〓〓〓〓〓〓〓〓〓★ ☆ 1.增加学生成绩 ☆ ★〓〓〓〓〓〓〓〓〓"<<endl; 2、用链表存储信息 * 程序头部的注释结束 3、约定的规范&#xff1a; 1界面设计简介&#xff0c;人性化…

php serialize error at offset,PHP Notice: unserialize(): Error at offset XX of XX bytes

之前同事在本地开发的时候&#xff0c;出现一个错误&#xff0c;如下图所示&#xff1a;字面意思就是反序列化错误&#xff0c;由此bug引申出来序列化和反序列化得应用&#xff0c;以及php array当key为string类型的数字值时&#xff0c;会发生什么情形。先来看序列化$str [1 …

Java ClassLoader setClassAssertionStatus()方法与示例

ClassLoader类setClassAssertionStatus()方法 (ClassLoader Class setClassAssertionStatus() method) setClassAssertionStatus() method is available in java.lang package. setClassAssertionStatus()方法在java.lang包中可用。 setClassAssertionStatus() method is used …

python怎么变各种颜色_python – 如何淡化颜色

有很多方法可以做到这一点.您如何选择这取决于您是否重视速度和简单性或感知均匀性.如果你需要它是真正统一的,你需要用颜色配置文件定义RGB颜色,你需要配置文件的原色,这样你就可以转换为XYZ,然后转换到LAB,你可以操作L通道. 大多数情况下,您不需要这样做,而是可以使用像Photo…

informatica中元数据管理

摘自&#xff1a; http://blog.itpub.net/28690368/viewspace-766528/ informaica是一个很强大的ETL工具&#xff0c;WORKFLOW MANAGER负责对ETL调度流程进行设计与管理和执行&#xff0c;informatica在资料库中提供以下表来存储调动流程的相关信息&#xff0c;以便WORKFLOW …

yii+php+当前目录,Yii应用的目录结构和入口脚本

以下是一个通过高级模版安装后典型的Yii应用的目录结构&#xff1a;~~~.├── backend├── common├── console├── environments├── frontend├── nbproject├── tests├── vendor├── composer.json├── composer.lock├── init├── init.bat├── …

8086 寻址方式_8086微处理器的不同寻址模式

8086 寻址方式Introduction: 介绍&#xff1a; Addressing mode tells us what is the type of the operand and the way they are accessed from the memory for execution of an instruction and how to fetch particular instruction from the memory. There are mainly 8 …

决策树的value是什么意思_从零开始的机器学习实用指南(六):决策树

类似SVM&#xff0c;决策树也是非常多功能的机器学习算法&#xff0c;可以分类&#xff0c;回归&#xff0c;甚至可以完成多输出的任务&#xff0c;能够拟合复杂的数据集&#xff08;比如第二章的房价预测例子&#xff0c;虽然是过拟合了。&#xff09;决策树也是很多集成学习的…

Hive中生成随机唯一标识ID的方法

2019独角兽企业重金招聘Python工程师标准>>> HIVE中处理的数据往往比较多&#xff0c;在处理数据的时候希望给处理得到的数据一个ID标识&#xff0c;这时候可以用到UUID。 UUID的算法的核心思想是结合机器的网卡、当地时间、一个随即数来生成UUID。从理论上讲&#…

php从网页获得数据,php根据URL获得网页内容

php 中根据url来获得网页内容非常的方便&#xff0c;可以通过系统内置函数file_get_contents(),传入url,即可返回网页的内容&#xff0c;比如获得百度首页的内容代码为&#xff1a;$html file_get_contents(http://www.baidu.com/);echo $html;就可以显示出百度首页的内容&…

2020知道python语言应用答案_2020知到Python语言应用答案章节期末答案

组合管理理论最早由哈维马科维兹于1962年系统的提出&#xff0c;他开创了对投资进行整体管理的先 公司型基金和契约型基金的区别&#xff0c;下列不包括&#xff08;&#xff09;。 A&#xff0e;资金的性质B&#xff0e;基金的营运依据C&#xff0e;基 我国&#xff08;&#…

如何在Bootstrap中使用Jumbotron和页面标头类?

Introduction 介绍 In the previous article, we have learned how Responsive column, Nesting Columns and offset Columns work and how to use them? I hope now, you all are comfortable with the grid system; what is it, how to use it and how we can use it for c…

python中的数字类型格式与运算,python数字数据类型

python数字数据类型1. 数字在我们很小的时候&#xff0c;父母便开始教我们数数&#xff0c;从1数到10&#xff0c;聪明的孩子可以数的更多。python支持3中数值类型整型(int)&#xff0c;通常称之为整型或整数&#xff0c;这个概念与我们小学时学过的整数是相同的&#xff0c;py…

getprocaddress得到为0_基于ZU+系列MPSoC芯片的USB3.0/2.0接口硬件设计

本文主要介绍Zynq UltraScale MPSoC系列芯片的USB3.0/2.0接口硬件设计。ZU系列MPSoC要实现USB3.0/2.0的全部功能&#xff0c;需要同时使用MIO和GTR。因为GTR接口中的USB接口只支持USB3.0&#xff0c;对USB2.0的支持需要通过MIO接口外接USB PHY实现。ZU系列MPSoC包括两个USB接口…

如何设置单词第一个字母大写_大写一行中每个单词的第一个和最后一个字母

如何设置单词第一个字母大写Problem statement: 问题陈述&#xff1a; Given an input line, capitalize first and last letter of each word in the given line. Its provided that the input line is in lowercase. 给定输入行&#xff0c; 将给定行中每个单词的第一个和最…

php如何编造简历,在简历里编造内容需要注意哪些问题?

在个人简历里编造内容可得有一定依据才行&#xff0c;总得为自己后期做个准备工作是不是&#xff1f;你编造的东西不只是给企业看一看而已&#xff0c;企业还会对这些内容作出进一步的判断&#xff0c;并且可能就其对你进行提问&#xff0c;如果你答不出来而曝光自己是在欺骗企…

Java LinkedList公共对象pollLast()方法(带示例)

LinkedList公共对象pollLast()方法 (LinkedList public Object pollLast() method) This method is available in package java.util.LinkedList.pollLast(). 软件包java.util.LinkedList.pollLast()中提供了此方法。 This method is used to retrieves the last or ending ele…

python编写学生成绩排序_Python实现按学生年龄排序的实际问题详解

前言 本文主要给大家了关于利用Python按学生年龄排序的相关内容&#xff0c;分享出来供大家参考学习&#xff0c;下面话不多说了&#xff0c;来一起看看详细的介绍&#xff1a; 问题&#xff1a;定义一个Class&#xff1a;包含姓名name、性别gender、年龄age&#xff0c;需要按…

前方危险-让很多“高逼格”高管深刻反思的文章

在很多的时候&#xff0c;现实会让我们每个人迷惑&#xff0c;周边的人和事可以让人极度的膨胀&#xff0c;你可以想吃了迷药一样&#xff0c;分不清是现实还是虚幻。很久以前&#xff0c;在公司的一次会议上&#xff0c;某主管告诉我们说&#xff0c;“他一个同事&#xff0c;…