CharArrayWriter类的size()方法 (CharArrayWriter Class size() method)

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

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

  • size() method is used to get the current size of this buffer (CharArrayWriter).

    size()方法用于获取此缓冲区的当前大小(CharArrayWriter)。

  • 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 current 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 this stream.

方法的返回类型为int ,它返回此流的当前大小。

Example:

例:

// Java program to demonstrate the example
// of int size() method of CharArrayWriter
import java.io.*;
public class SizeOfCAW {public static void main(String[] args) {CharSequence cs = "Java World!!!";
CharArrayWriter caw = null;
try {// Instantiates CharArrayWriter
caw = new CharArrayWriter();
// By using append() method is to
// append cs to the caw before calling
// reset()
caw.append(cs);
// By using toString() method is
// to represent the caw as a string
System.out.print("caw: " + caw.toString());
System.out.println();
// By using size() method isto return
// the size of this stream
int size = caw.size();
// Display size of the stream
System.out.print("caw.size(): " + size);
} catch (Exception ex) {System.out.println(ex.toString());
} finally {// Free all resources linked with this
// stream
if (caw != null)
caw.close();
}
}
}

Output

输出量

caw: Java World!!!
caw.size(): 13

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

Java CharArrayWriter 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. 【深度学习】(6) tensorflow2.0使用keras高层API
  2. 为什么谐振时电抗为0_变频串联谐振试验装置的接线原理
  3. 一个自己写的PHP模板引擎
  4. 域名”A记录,MX记录,CNAME记录,TTL值,URL转发”解释
  5. 反射获取空参数成员方法并运行
  6. 问题:linux系统经常出现断网的情况,重启之后系统恢复正常
  7. 达摩院送你100万,请坚持“看月亮”
  8. linux shell if -a 到-z参数含义
  9. ZT云流量软件官网响应式HTML模板
  10. STC51-C51基础知识
  11. POJ 3308 Paratroopers (对数转换+最小点权覆盖)
  12. sql server序列_SQL Server中身份和序列之间的区别
  13. ​CSDN疯狂盲盒来啦!iPhone 12、机械键盘、Switch等你来拿!
  14. Table 'xxx' doesn't exist
  15. 过去的2017和已经到来的2018
  16. PHP团队 编码规范 代码样式风格规范
  17. php 多附件上传插件下载,大文件、多文件分片上传插件
  18. QT系列之曲线图绘制(推荐QCustomPlot)
  19. 信息加密技术——对称密码体制
  20. cmd中如何运行python文件_在cmd中运行.py文件: python的操作步骤

热门文章

  1. 插件properties_Mybatis3系列 - 4. mybatis-config的properties属性详解
  2. ac2100 反弹shell无法粘贴_记一次突破反弹shell
  3. 大型网站的HTTPS实践:基于协议和配置的优化
  4. Problem A: 判断操作是否合法(栈和队列)
  5. 怎么样修改PuTTY的默认字体和字符集
  6. 前端路由的两种实现原理
  7. MyBatis-进阶2
  8. 工业智能相机与基于PC的机器视觉的区别比较
  9. codevs3872 邮递员送信(SPFA)
  10. 同事反馈环:如何实现持续改进的文化