package com.mot.labs.ucsl.util;

import java.io.IOException;
import java.io.InputStream;

import javax.microedition.io.Connector;

import com.motorola.io.FileConnection;

public class BufferedInputReader {

	InputStream is;
	
	public BufferedInputReader(InputStream is) {
		this.is = is;
	}
	
	public static InputStream getInputStream(String filename) throws IOException {
		FileConnection sc = (FileConnection)Connector.open(filename);
		InputStream is = sc.openInputStream();
		return is;
	}
		
	public String readLine() throws IOException {
		StringBuffer sofar = new StringBuffer();
		byte c;
		while (((c = (byte)is.read()) != -1) && (c != '\n')){
			sofar.append((char)c);
		}
		if (sofar.length() == 0) {
			return null;
		}
		else {
			return sofar.toString();
		}
	}
}
