/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package runner;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author doo
 */
public class InputStreamThread extends Thread {
	private static BufferedReader br;
	private List<String> list = new ArrayList<String>();

	/** コンストラクター */
	public InputStreamThread(InputStream is) {
		br = new BufferedReader(new InputStreamReader(is));
	}

	/** コンストラクター */
	public InputStreamThread(InputStream is, String charset) {
		try {
			br = new BufferedReader(new InputStreamReader(is, charset));
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		}
	}

	@Override
	public void run() {
		for (;;) {
			try {
				String line = br.readLine();
				if (line == null) 	break;
				list.add(line);
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

	/** 文字列取得 */
	public List<String> getStringList() {
		return list;
	}
	public BufferedReader getBuffer(){
		return br;
	}
 }
