stringwriter_Java StringWriter getBuffer()方法与示例

stringwriter

StringWriter类的getBuffer()方法 (StringWriter Class getBuffer() method)

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

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

  • getBuffer() method is used to get the StringBuffer that holds the present buffer value.

    getBuffer()方法用于获取保存当前缓冲区值的StringBuffer。

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

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

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

    返回StringBuffer时, getBuffer()方法不会引发异常。

Syntax:

句法:

    public StringBuffer getBuffer();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is StringBuffer, it returns the StringBuffer itself that holds the current buffer value.

该方法的返回类型为StringBuffer ,它返回保存当前缓冲区值的StringBuffer本身。

Example:

例:

// Java program to demonstrate the example 
// of StringBuffer getBuffer() method of StringWriter
import java.io.*;
public class GetBufferOfFSW {
public static void main(String[] args) throws Exception {
StringWriter str_w = null;
String str = "Java World!!!";
try {
// Instantiates StringWriter
str_w = new StringWriter();
str_w.write(str);
// By using getBuffer() method is to
// get the buffer of this str_w stream
StringBuffer str_b = str_w.getBuffer();
System.out.println("str_w.getBuffer(): " + str_b);
} catch (Exception ex) {
System.out.println(ex.toString());
} finally {
// with the help of this block is to
// free all necessary resources linked
// with the stream
if (str_w != null) {
str_w.close();
}
}
}
}

Output

输出量

str_w.getBuffer(): Java World!!!

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

stringwriter

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541743.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

linux 下邮件服务器,Linux 下搭建Postfix邮件服务器

Linux 下搭建Postfix邮件服务器详解:1、首先关闭sendmail服务service sendmail stop2、chkconfig sendmail off(关闭开机自启动)3、修改DNS正解文件,使DNS能够解析邮箱服务添加下面两行mail.zhubf.com. IN A 172.17.17.2zhubf.com. IN M…

Java PipedInputStream close()方法与示例

PipedInputStream类close()方法 (PipedInputStream Class close() method) close() method is available in java.io package. close()方法在java.io包中可用。 close() method is used to close this PipedInputStream and free all system resources linked with this stream…

Coreseek Windows下安装调试

由于项目需要全文检索,后面就去网上查了下资料,找到了Sphinx【中文是狮身人面像】这个全文检索引擎,听说挺好用的,不过没有中文分词。后面又去找了一下,找到了Coreseek,一款中文全文检索/搜索软件。 一、Sp…

linux sudo命令全称,linux sudo命令的概念与使用

1.sudo介绍本文引用地址:http://www.eepw.com.cn/article/201610/305498.htmsudo是linux下常用的允许普通用户使用超级用户权限的工具,允许系统管理员让普通用户执行一些或者全部的root命令,如halt,reboot,su等等。这样…

java 方法 示例_Java语言环境getISOCountries()方法与示例

java 方法 示例区域设置类getISOCountries()方法 (Locale Class getISOCountries() method) getISOCountries() method is available in java.util package. getISOCountries()方法在java.util包中可用。 getISOCountries() method is used to return an array of string that …

android shape.xml 属性详解

转载源:http://blog.csdn.net/harvic880925/article/details/41850723 一、简单使用 刚开始,就先不讲一堆标签的意义及用法,先简单看看shape标签怎么用。 1、新建shape文件 首先在res/drawable文件夹下,新建一个文件,命名为&#…

linux检查防火墙是否阻挡端口,浅析linux查看防火墙状态和对外开放的端口状态...

1.查看防火墙状态查看防火墙状态 systemctl status firewalld开启防火墙 systemctl start firewalld关闭防火墙 systemctl stop firewalld开启防火墙 service firewalld start若遇到无法开启先用:systemctl unmask firewalld.service然后:systemctl star…

Java类class getClasses()方法及示例

类的类getClasses()方法 (Class class getClasses() method) getClasses() method is available in java.lang package. getClasses()方法在java.lang包中可用。 getClasses() method is used to return an array that contains Class objects denoting all the public classes…

linux内核计数函数,linux中的内核引用计数器

linux中的内核引用计数器文档 /Documentation/kref.txt翻译。krefs能让你往你的对象中添加一个引用计数器。如果你有一些需要在多处被使用和传递的对象,而你并没有给这些对象中添加引用计数器的话,你的代码肯定会有某些缺陷,会出现一些问题。…

jQuery常用的全局方法源码

下面常用方法的详细使用请查看:http://www.cnblogs.com/moqiutao/p/4775725.html 1.$.noConflict()方法 语法:jQuery.noConflict(removeAll) removeAll:布尔值。指示是否允许彻底将 jQuery 变量还原。 源码: var// Map over jQuer…

isinstance_Java类class isInstance()方法及示例

isinstance类class isInstance()方法 (Class class isInstance() method) isInstance() method is available in java.lang package. isInstance()方法在java.lang包中可用。 isInstance() method is used to check whether the given object is an instance with the object d…

Linux比较大文件内容,Linux系统最大文件打开数优化,解决Too many open files报错

这是一个Linux系统常见的故障,网络上也能轻易的找到解决办法,我也只是在工作中遇到了这个问题,所以在博客记录下,以备不时之需。一、报错截图:图为resin的报错日志,很明显提示了Too many open files&#x…

java日历类add方法_Java日历computeFields()方法及示例

java日历类add方法日历类的computeFields()方法 (Calendar Class computeFields() method) computeFields() method is available in java.util package. 在java.util包中提供了validateFields()方法 。 computeFields() method is used to convert current ms(milliseconds) t…

Varnish缓存代理简介与配置

一、varnish原理:1)Varnish简介:varnish缓存是web应用加速器,同时也作为http反向缓存代理。你可以安装varnish在任何http的前端,同时配置它缓存内容。与传统的 squid 相比,varnish 具有性能更高、速度更快、…

Linux允许61440端口,释放对某端口的占用

释放对某端口的占用假如我们需要确定谁占用了我们的9050端口在windows命令行窗口下执行:1.查看所有的端口占用情况C:\>netstat -ano协议 本地地址 外部地址 状态 PIDTCP 127.0.0.1:1434 0.0.…

as_hash ruby_Hash.merge(other_hash)方法与Ruby中的示例

as_hash rubyHash.merge(other_hash)方法 (Hash.merge(other_hash) Method) In this article, we will study about Hash.merge(other_hash) Method. The working of the method can’t be assumed because it’s quite a different name. Let us read its definition and unde…

linux 安装nfs 客户端,在CentOS 7上安装NFS服务器和客户端

NFS服务器和客户端安装在CentOS 7上版本1.0作者:Srijan Kishore 在Twitter上关注howtoing最后编辑 16 / Dec / 2014本指南介绍如何在CentOS 7.0中配置NFS服务器网络文件系统(NFS)是一种流行的分布式文件系统协议,可让用户在其服务器上安装远程目录。 该系…

安装ORACLE 时报错 /jre/1.4.2/lib/i386/libawt.so:

最近在linux下安装oracle 10g时,碰到如下问题: /tmp/OraInstall2011-09-11_02-16-11PM/jre/1.4.2/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory occurred.. 网上找了下,真让人费解呀&am…

Java线程start()vs run()方法及示例

Java | 线程start()vs run()方法 (Java | Thread start() vs run() Methods) When we call the start() method, it leads to the creation of a new thread. Then, it automatically calls the run() method. If we directly call the run() method, then no new thread will …

linux安装卸载mysql,Linux6 系列 安装、卸载mysql

Linux6 系列 安装、卸载mysqlLinux6 系列 安装、卸载mysqlLinux环境下载mysql:https://blog.csdn.net/weixin_40816738/article/details/90111456一、安装环境依赖:yum install -y cmake make gcc gcc-c libaio ncurses ncurses-devel二、安装流程1、软件…