package ohjava;

import java.io.*;

public class InputFile {

  InputStream fin;

  public InputFile() {
    fin = null;
  }

  public boolean openFile(String fn) { 
    try {
      fin = new FileInputStream(fn);
    } catch (Exception e) {
        return false;
      }
    return true;
  }

  public String readLine() throws Exception {
    String line="";
    char ch;

    try {
      ch = (char) fin.read();
    } catch (Exception e) {
        return null;
      }
    while (ch != '\n') {
      line += ch;
      try {
        ch = (char) fin.read();
      } catch (Exception e) {
          break;
        }
    }
    return line;
  } 

  public void closeFile() {
    fin = null;
  }
}