Java CharArrayWriter size()方法与示例
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()方法与示例相关推荐
- Java IOUtils.copy方法代码示例(亲测)
本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...
- Java 中array.size()_Java ArrayDeque size()方法与示例
ArrayDeque类size()方法size()方法在java.lang包中可用. size()方法用于返回存储在此双端队列中的大小(元素数). size()方法是一个非静态方法,只能通过类对象访问 ...
- Java List.size()方法:返回列表中元素的个数(亲测)
Java 集合类中的 List.size() 方法以 int 形式返回列表中元素的个数. 语法: size() 返回列表中元素的个数.如果列表中元素的个数超过 2 147 483 647,则返回 2 ...
- java user directory,Java ProcessBuilder directory()方法与示例
语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...
- Java序列化魔术方法及其示例使用
在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...
- catalog java,Java Connection getCatalog()方法与示例
通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...
- filepermission java,Java FilePermission getActions()方法与示例
FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...
- java方法参数Bundle,Java ResourceBundle keySet()方法及示例
ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...
- java exec waitfor,Java Process waitFor()方法与示例
流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...
最新文章
- 【深度学习】(6) tensorflow2.0使用keras高层API
- 为什么谐振时电抗为0_变频串联谐振试验装置的接线原理
- 一个自己写的PHP模板引擎
- 域名”A记录,MX记录,CNAME记录,TTL值,URL转发”解释
- 反射获取空参数成员方法并运行
- 问题:linux系统经常出现断网的情况,重启之后系统恢复正常
- 达摩院送你100万,请坚持“看月亮”
- linux shell if -a 到-z参数含义
- ZT云流量软件官网响应式HTML模板
- STC51-C51基础知识
- POJ 3308 Paratroopers (对数转换+最小点权覆盖)
- sql server序列_SQL Server中身份和序列之间的区别
- ​CSDN疯狂盲盒来啦!iPhone 12、机械键盘、Switch等你来拿!
- Table 'xxx' doesn't exist
- 过去的2017和已经到来的2018
- PHP团队 编码规范 代码样式风格规范
- php 多附件上传插件下载,大文件、多文件分片上传插件
- QT系列之曲线图绘制(推荐QCustomPlot)
- 信息加密技术——对称密码体制
- cmd中如何运行python文件_在cmd中运行.py文件: python的操作步骤