Java ByteArrayOutputStream reset()方法及示例

ByteArrayOutputStream類reset()方法 (ByteArrayOutputStream Class reset() method)

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

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

  • reset() method is used to reset this stream (i.e. it removes all currently consumed output in this stream and reset the variable count is set to 0).

    reset()方法用于重置此流(即,它將刪除此流中所有當前消耗的輸出,并將變量計數重置為0)。

  • reset() 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.

    reset()方法是一種非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • reset() method does not throw an exception at the time of resetting the stream.

    reset()方法在重置流時不會引發異常。

Syntax:

句法:

    public void reset();

Parameter(s):

參數:

  • It does not accept any parameter.

    它不接受任何參數。

Return value:

返回值:

The return type of the method is void, it returns nothing.

該方法的返回類型為void ,不返回任何內容。

Example:

例:

// Java program to demonstrate the example 
// of void reset()  method of ByteArrayInputStream
import java.io.*;
public class ResetOfBAOS {
public static void main(String[] args) throws Exception {
byte b1 = 97;
byte b2 = 100;
ByteArrayOutputStream BAOS = null;
try {
// Instantiates ByteArrayOutputStream
BAOS = new ByteArrayOutputStream();
// By using write() method is to
// write b1 to the BAOS
BAOS.write(b1);
// By using toString() method is 
// to represent the b1 as a string
// before using reset()
System.out.println("BAOS.write(b1): " + BAOS.toString());
// By using reset() method is
// to reset the stream
BAOS.reset();
// By using write() method is to
// write b2 to the BAOS 
BAOS.write(b2);
// By using toString() method is 
// to represent the b2 as a string
// after using reset()
System.out.println("BAOS.write(b2): " + BAOS.toString());
} catch (Exception ex) {
System.out.println(ex.toString());
} finally {
if (BAOS != null)
BAOS.close();
}
}
}

Output

輸出量

BAOS.write(b1): a
BAOS.write(b2): d

翻譯自: https://www.includehelp.com/java/bytearrayoutputstream-reset-method-with-example.aspx

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/379619.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/379619.shtml
英文地址,請注明出處:http://en.pswp.cn/news/379619.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

使用存儲過程修改sql server 2005 用戶密碼

exec sp_password null,新密碼,用戶名轉載于:https://www.cnblogs.com/SXLBlog/archive/2009/07/10/1520590.html

winform TopMost

當設置winform窗體的TopMost屬性為true時,有時會出現不好使的狀況,這可能是因為窗體設置了MdiParent屬性。轉載于:https://www.cnblogs.com/magic-cube/archive/2012/06/10/2544216.html

Linux內核設計與實現---進程地址空間

進程地址空間1 內存描述符分配內存描述符銷毀內存描述符mm_struct與內核線程2 內存區域VMA標志VMA操作內存區域的樹形結構和內存區域的鏈表結構3 操作內存區域find_vma()find_vma_prev()find_vma_intersection()4 mmap()和do_mmap():創建地址空間mmap(&a…

JavaScript中帶有示例的Math.log10()方法

JavaScript | Math.log10()方法 (JavaScript | Math.log10() Method) Math operations in JavaScript are handled using functions of math library in JavaScript. In this tutorial on Math.log10() method, we will learn about the log10() method and its working with e…

JSP技術

一、jsp腳本和注釋 jsp腳本&#xff1a; 1&#xff09;<%java代碼%> ----- 內部的java代碼翻譯到service方法的內部 2&#xff09;<%java變量或表達式> ----- 會被翻譯成service方法內部out.print() 3&#xff09;<%!java代碼%> ---- 會被翻譯成servlet的成…

jQuery.ajax不能實現return值調用問題

我們使用jQuery.ajax函數是不能實現success方法return值的&#xff0c;而有時候我們需要對成功返回的數據進行處理&#xff0c;一般來說&#xff0c;與服務器交互后會返回很多的數據&#xff0c;而有些數據需要進行特別處理&#xff0c;這時需要實現success方法return&#xff…

Linux內核設計與實現---頁高速緩存和頁回寫

頁高速緩存和頁回寫1 頁高速緩存2 基樹3 緩沖區高速緩存4 pdflush后臺例程膝上型電腦模式bdflush和kupdated避免擁塞的方法&#xff1a;使用多線程頁高速緩存&#xff08;cache&#xff09;是Linux內核實現的一種主要磁盤緩存&#xff0c;通過把磁盤中的數據緩存到物理內存中&a…

EL技術

1&#xff0e;EL 表達式概述 EL&#xff08;Express Lanuage&#xff09;表達式可以嵌入在jsp頁面內部&#xff0c;減少jsp腳本的編寫&#xff0c;EL 出現的目的是要替代jsp頁面中腳本的編寫。 2&#xff0e;EL從域中取出數據(EL最重要的作用) jsp腳本&#xff1a;<%requ…

math.trunc_JavaScript中帶有示例的Math.trunc()方法

math.truncJavaScript | Math.trunc()方法 (JavaScript | Math.trunc() Method) Math.trunc() is a function in math library of JavaScript that is used to extract the integer part of the given floating-point number. It removes the decimal and all the digits after…

.NET程序員的書單

zz from sjtu bbs: http://bbs.sjtu.edu.cn/bbscon?boardDotNET&fileM.1126188158.A 發信人: luckySeven(lucky為這位mm默哀), 信區: DotNET 標 題: .NET程序員的書單 發信站: 飲水思源 (2005年09月08日22:02:45 星期四), 轉信 發信人: AtomAndBit (原子與比特), 信區: D…

SVN+AnkhSVN端配置

對于ankhSVN我想很多人不陌生&#xff0c;因為經常使用&#xff0c;但是我還是發現很多人并不怎么會配置&#xff0c;或者完全不知道其需要配置&#xff0c;如果不配置的話&#xff0c;當兩個人同時需要修改某個文件的時候就容易中彈了。SVN默認是不支持“鎖定-編輯-解鎖”的&a…

Linux內核設計與實現---模塊

模塊1 構建模塊放在內核源代碼樹中放在內核代碼外2 安裝模塊3 產生模塊依賴性4 載入模塊5 管理配置選項6 模塊參數7 導出符號表Linux內核是模塊化組成的&#xff0c;它允許內核在運行時動態地向其中插入或從中刪除代碼。 與開發的內核核心子系統不同&#xff0c;模塊開發更接近…

JSTL技術

1&#xff0e;JSTL概述 JSTL&#xff08;JSP Standard Tag Library)&#xff0c;JSP標準標簽庫&#xff0c;可以嵌入在jsp頁面中使用標簽的形式完成業務邏輯等功能。jstl出現的目的同el一樣也是要代替jsp頁面中的腳本代碼。JSTL標準標準標簽庫有5個子庫&#xff0c;但隨著發展…

asinh函數_JavaScript中帶有示例的Math.asinh()方法

asinh函數JavaScript | Math.asinh()方法 (JavaScript | Math.asinh() Method) Math.asinh() is a function in math library of JavaScript that is used to find the value of hyperbolic arc-sine of a number. Math.asinh()是JavaScript數學庫中的函數&#xff0c;用于查找…

使用PHP創建一個REST API(Create a REST API with PHP)

譯者前言&#xff1a; 首先這是一篇國外的英文文章&#xff0c;非常系統、詳盡的介紹了如何使用PHP創建REST API&#xff0c;國內這方面的資料非常非常的有限&#xff0c;而且基本沒有可操作性。這篇文章寫的非常好&#xff0c;只要對PHP稍有了解的程序員&#xff0c;看完本文基…

old-

大數問題:求用一段C或C程序寫求 f(x)100! 的完整程序大數問題&#xff0c; 我用數組作的&#xff0c;輸出格式應該是是222,222,222 #include "stdafx.h" #include<stdio.h> #include<stdlib.h> int a[1000]{0}; in…

javaEE的開發模式

1&#xff0e;什么是模式 模式在開發過程中總結出的“套路”&#xff0c;總結出的一套約定俗成的設計模式 2&#xff0e;javaEE經歷的模式 model1模式&#xff1a; 技術組成&#xff1a;jspjavaBean model1的弊端&#xff1a;隨著業務復雜性 導致jsp頁面比較混亂 model2模式…

Linux內核設計與實現---kobject sysfs

kobject sysfs1 kobject2 ktype3 kset4 subsystem5 別混淆了這些結構體6 管理和操作kobject7 引用計數kref8 sysfssysfs中添加和刪除kobject向sysfs添加文件9 內核事件層2.6內核增加了一個引人注目的新特性—同一設備模型。設備模型提供了獨立的機制專門表示設備&#xff0c;并…

開發Windows Mobile今日插件 -- 內存電量,桌面便箋,桌面記單詞

本篇文章講解的是開發 Windows Mobile 上的今日插件。關于是今日插件&#xff0c;在 PPC 或者 SP SDK 的幫助文檔中有相關的章節介紹&#xff0c;在網絡上也有一些帖子和資源講解。在這里簡要回顧一下。今日插件就是在windows mobile的桌面上顯示的條目&#xff0c;例如系統提供…

c語言中將函數指針作為形參_在C中將有效指針作為NULL指針

c語言中將函數指針作為形參Prerequisite: An Example of Null pointer in C 先決條件&#xff1a; C中的空指針示例 Any pointer that contains a valid memory address can be made as a NULL pointer by assigning 0. 通過分配0&#xff0c;可以將包含有效內存地址的任何指…