Java.io.StringWriter.append()方法实例

算法 ww9992019com 发表于 1 周前

www.9951026.net开户请拨15894452300中国新说唱南京雨花台区JDTUKn<div style="width:100%;float:left;" class="article-content">

                <input type="hidden" name="article_id" id="article_id" value="3248">
                <input type="hidden" name="catid" id="catid" value="0">

                <p>

<strong>java.io.StringWriter.append() </strong>方法将指定字符追加到这个writer。</p>

<h2>

声明</h2>

<p>

以下是java.io.StringWriter.append()方法的声明</p>

<pre class="prettyprint prettyprinted">

<span class="kwd">public</span><span class="pln"> </span><span class="typ">StringWriter</span><span class="pln"> append</span><span class="pun">(</span><span class="kwd">char</span><span class="pln"> c</span><span class="pun">)</span></pre>

<h2>

参数</h2>

<ul>

<li>

    <p>

        c -- 16位字符以附加</p>

</li>

</ul>

<h2>

返回值</h2>

<p>

此方法返回这个writer。</p>

<h2>

异常</h2>

<ul>

<li>

    <p>

        NA</p>

</li>

</ul>

<h2>

例子</h2>

<p>

下面的示例演示java.io.StringWriter.append()方法的用法。</p>

<pre class="prettyprint prettyprinted">

<span class="kwd">package</span><span class="pln"> com</span><span class="pun">.</span><span class="pln">yiibai</span><span class="pun">;</span><span class="pln">

</span><span class="kwd">import</span><span class="pln"> java</span><span class="pun">.</span><span class="pln">io</span><span class="pun">.*;</span><span class="pln">

</span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">class</span><span class="pln"> </span><span class="typ">StringWriterDemo</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

</span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> main</span><span class="pun">(</span><span class="typ">String</span><span class="pun">[]</span><span class="pln"> args</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

  </span><span class="com">// create a new writer</span><span class="pln">

  </span><span class="typ">StringWriter</span><span class="pln"> sw </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">StringWriter</span><span class="pun">();</span><span class="pln">



  </span><span class="com">// append a char       </span><span class="pln">

  </span><span class="typ">System</span><span class="pun">.</span><span class="kwd">out</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="str">""</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> sw</span><span class="pun">.</span><span class="pln">append</span><span class="pun">(</span><span class="str">"a"</span><span class="pun">));</span><span class="pln">

  </span><span class="typ">System</span><span class="pun">.</span><span class="kwd">out</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="str">""</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> sw</span><span class="pun">.</span><span class="pln">append</span><span class="pun">(</span><span class="str">"b"</span><span class="pun">));</span><span class="pln">

</span><span class="pun">}</span><span class="pln">

</span><span class="pun">}</span></pre>

<p>

Let us compile and run the above program, this will produce the following result</p>

<pre class="prettyprint prettyprinted">

<span class="pln">a

ab</span></pre>

                <br>
                <p style="text-align:center;float:left;width:100%;margin-top:24px;margin-bottom:18px;">
                        <button class="layui-btn layui-btn-danger" id="btn-reward"> ¥ 我要打赏 </button>  
                        <button class="layui-btn" id="article-perfect">
                            <i class="layui-icon layui-icon-edit"></i>教程纠错
                        </button>
                        <button class="layui-btn layui-btn-normal" id="action-collection">
                            <i class="layui-icon layui-icon-rate"></i>收藏
                        </button>
                </p>



                <div style="width:100%;margin-bottom: 16px; height: 32px;margin-top:18px;float:left;">

                    <span style="float:left;">上一篇:<a href="http://f2e.im/u/ww9992019com" title="Java.io.StringWriter类"><i class="layui-icon"></i>
                            Java.io.StringWriter类</a></span>
                                            <span style="float:right;">下一篇:<a href="http://f2e.im/u/ww9992019com" style="float:right;" title="下一篇:java.io.StringWriter.append(CharSequence csq)方法实例"><i class="layui-icon"></i>
                            java.io.StringWriter.append(CharSequence csq)方法实例</a></span>
                                            <div id="googlead" style="float:left;margin-top:8px;">
                        <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                        <!-- yiibai下方 -->
                        <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-1090193214637198" data-ad-slot="6494738921"></ins>
                        <script>
                            (adsbygoogle = window.adsbygoogle || []).push({});
                        </script>
                    </div>
                </div>

                <div style="width:100%;margin-top:18px;float:left;">


            </div>
暂无回复,说出你的观点吧
登录后即可参与回复