java.io.StringWriterのサンプル

サンプルコード

package com.arkgame;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringWriter;

public class StringWriterDemo {

	public static void main(String[] args) throws IOException {
		char[] cc = new char[1024];
		StringWriter st = new StringWriter();
		FileInputStream fis = null;
		BufferedReader bfr = null;
		fis = new FileInputStream("c://cft.txt");
		bfr = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
		int s;
		while ((s = bfr.read(cc)) != -1) {
			st.write(cc, 0, s);
		}
		System.out.println(st.toString());
		st.close();
		bfr.close();

	}

}

Java

Posted by arkgame