博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java CharArrayWriter reset()方法及示例
阅读量:2534 次
发布时间:2019-05-11

本文共 2020 字,大约阅读时间需要 6 分钟。

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

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

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

  • reset() method is used to reset this stream (CharArrayWriter) and it can re-use further without throwing away.

    reset()方法用于重置此流(CharArrayWriter),并且可以进一步重用而不会丢弃。

  • 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 CharArrayWriterimport java.io.*;public class ResetOfCAW {
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 reset() method isto reset the // caw stream caw.reset(); // Define CharSequence again cs = "Java Programming!!!!"; // By using append() method is to // append new cs to the caw after calling // reset() caw.append(cs); // By using toString() method is // to represent the caw as a string System.out.print("caw.reset(): " + caw.toString()); } 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.reset(): Java Programming!!!!

翻译自:

转载地址:http://kvvzd.baihongyu.com/

你可能感兴趣的文章
form表单序列化后的数据转json对象
查看>>
[PYTHON]一个简单的单元測试框架
查看>>
iOS开发网络篇—XML数据的解析
查看>>
[BZOJ4303]数列
查看>>
数据库TCPIP协议开了,但还是远程连不上
查看>>
一般处理程序在VS2012中打开问题
查看>>
C语言中的++和--
查看>>
thinkphp3.2.3入口文件详解
查看>>
POJ 1141 Brackets Sequence
查看>>
Ubuntu 18.04 root 使用ssh密钥远程登陆
查看>>
linux 单机跨进程通信
查看>>
Servlet和JSP的异同。
查看>>
虚拟机centOs Linux与Windows之间的文件传输
查看>>
ethereum(以太坊)(二)--合约中属性和行为的访问权限
查看>>
IOS内存管理
查看>>
监听系统键盘的方法
查看>>
Mysql两个引擎对比
查看>>
测试书籍推荐
查看>>
php魔术方法
查看>>
BZOJ4025 : 二分图
查看>>