ByteArrayOutputStream类size()方法 (ByteArrayOutputStream Class size() method)

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

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

  • size() method is used to return the current size of the buffer exists.

    size()方法用于返回缓冲区当前存在的大小。

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

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

  • size() method does not throw an exception at the time of returning the size.

    在返回大小时, size()方法不会引发异常。

Syntax:

句法:

    public int size();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is int, it returns the current size of the buffer exists in this stream.

方法的返回类型为int ,它返回此流中存在的缓冲区的当前大小。

Example:

例:

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

Output

输出量

BAOS.toString(): abcd
BAOS.size(): 4

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

Java ByteArrayOutputStream size()方法与示例相关推荐

  1. Java IOUtils.copy方法代码示例(亲测)

    本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...

  2. Java 中array.size()_Java ArrayDeque size()方法与示例

    ArrayDeque类size()方法size()方法在java.lang包中可用. size()方法用于返回存储在此双端队列中的大小(元素数). size()方法是一个非静态方法,只能通过类对象访问 ...

  3. Java List.size()方法:返回列表中元素的个数(亲测)

    Java 集合类中的 List.size() 方法以 int 形式返回列表中元素的个数. 语法: size() 返回列表中元素的个数.如果列表中元素的个数超过 2 147 483 647,则返回 2 ...

  4. java user directory,Java ProcessBuilder directory()方法与示例

    语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...

  5. Java序列化魔术方法及其示例使用

    在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...

  6. catalog java,Java Connection getCatalog()方法与示例

    通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...

  7. filepermission java,Java FilePermission getActions()方法与示例

    FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...

  8. java方法参数Bundle,Java ResourceBundle keySet()方法及示例

    ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...

  9. java exec waitfor,Java Process waitFor()方法与示例

    流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...

最新文章

  1. zookeeper在搭建的时候,解决后台启动为standalone模式问题
  2. monty python life of brian-电影Life of Brian 万世魔星
  3. Windows SDK程序的输出文字和格式控制(wsprintf、swprintf、Textout)
  4. win7装64位oracle和PLSQL
  5. IDEA使用从Eclipse过来的快捷键
  6. 夜深了,发点无聊的东西
  7. 东北考生到南方学计算机,为啥东北考生都想去南方,而南方学生很少考东北,看看他们怎么说...
  8. -42%!新能源补贴退坡后 比亚迪2019年利润几乎砍半
  9. Java Web学习总结(23)——Distributed Configuration Management Platform(分布式配置管理平台)
  10. Spring MVC类型转换的意义
  11. 小Q正在给一条长度为n的道路设计路灯安置方案。 为了让问题更简单,小Q把道路视为n个方格,需要照亮的地方用'.'表示, 不需要照亮的障碍物格子用'X'表示。
  12. mysql数据库管理工具navicat for mysql怎么用
  13. ab压力测试-Windows安装使用:
  14. 类别不平衡问题之SMOTE算法(Python imblearn极简实现)
  15. 使用 RetroShare 分享资源
  16. OkHttp简单封装
  17. 人工神经网络——学习策略
  18. -moz、-ms、-webkit, -o各什么意思
  19. 多数互联网人对2021年终奖不抱期待
  20. 2. TortoiseGit安装与配置

热门文章

  1. php 下拉菜单多选get,Jquery实现select二级联动多选下拉菜单
  2. 雅马哈php mt7,雅马哈专业录音室监听耳机 HPH-MT7 正式发售!
  3. bash --config command not found 报错
  4. AttributeError: 'NoneType' object has no attribute 'astype'
  5. Spark初识-弹性分布式数据集RDD
  6. windows下Apache虚拟主机配置
  7. img标签里的value获取
  8. cf375D. Tree and Queries(莫队)
  9. requests库入门09-OAUTH认证
  10. 百度之星初赛(A)——T5