Java StringWriter write()方法

java.io.StringWriter.write(int c) 方法写入单个字符。

1 语法

public void write(int c)

2 参数

c:int指定要写入的字符。

3 返回值

4 示例 

package com.yiidian;

/**
 * 一点教程网: http://www.yiidian.com
 */
/**
 * java.io.StringWriter.write()方法的例子
 */
import java.io.*;

public class Demo {
    public static void main(String[] args) {

        // create a new writer
        StringWriter sw = new StringWriter();

        // write integers that correspond to ascii code
        sw.write(70);
        sw.write(76);

        // print result by converting to string
        System.out.println("" + sw.toString());
    }
}

输出结果为:

FL

热门文章

优秀文章