/* * Copyright 2014 by SCSK Corporation. * * This file is part of PrimeCloud Controller(TM). * * PrimeCloud Controller(TM) is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * PrimeCloud Controller(TM) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with PrimeCloud Controller(TM). If not, see <http://www.gnu.org/licenses/>. */ package jp.primecloud.auto.iaasgw; 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; /** * InputStreamを読み込むスレッド */ public class StreamThread extends Thread { private BufferedReader br; private List<String> list = new ArrayList<String>(); /** コンストラクター */ public StreamThread(InputStream is) { br = new BufferedReader(new InputStreamReader(is)); } /** コンストラクター */ public StreamThread(InputStream is, String charset) { try { br = new BufferedReader(new InputStreamReader(is, charset)); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } @Override public void run() { try { for (;;) { String line = br.readLine(); if (line == null) break; list.add(line); } } catch (IOException e) { throw new RuntimeException(e); } finally { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } /** 文字列取得 */ public List<String> getStringList() { return list; } }