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.pswp.cn/news/542517.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542517.shtml
英文地址,請注明出處:http://en.pswp.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;…