// ================================================================
// John Kerl
// kerl.john.r@gmail.com
// 2005-05-02
// ================================================================

import java.util.*;
import java.io.*;

public class TextFileReader {

	// ----------------------------------------------------------------
	// Reads the input stream (nominally, System.in) and returns a
	// vector of strings containing the stream contents, one per line.
	// The strings do not contain the carriage return or line feed.
	public static Vector readInputStream(InputStream inputStream)
		//throws java.io.IOException
	{
		Vector lines = new Vector();
		// System.in ... support file I/O ... check if arg fn == "-".
		// Separate method?  readInputFile?
		InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
		BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
		String line = "";
		boolean done = false;

		while (!done) {
			try {
				line = bufferedReader.readLine();
			}
			catch (java.io.IOException e) {
				System.out.println("Caught I/O exception.\n");
				System.exit(1);
			}
			if (line == null)
				done = true;
			else
				lines.addElement(line);
		}

		return lines;
	}

	// ----------------------------------------------------------------
	public static void dump(Vector stringList)
	{
		for (int i = 0; i <  stringList.size(); i++) {
			System.out.println("Line: " + i + ": <<" + stringList.elementAt(i)
				+ ">>");
		}
	}
}
