FileDocCategorySizeDatePackage
ModelInterpreter.javaAPI DocAndroid 1.5 API18167Wed May 06 22:42:02 BST 2009com.android.internal.telephony.test

LineReader

public class LineReader extends Object

Fields Summary
static final int
BUFFER_SIZE
Not threadsafe Assumes input is ASCII
byte[]
buffer
InputStream
inStream
Constructors Summary
LineReader(InputStream s)


      
    
        inStream = s;
    
Methods Summary
java.lang.StringgetNextLine()

        return getNextLine(false);
    
java.lang.StringgetNextLine(boolean ctrlZ)
Note: doesn't return the last incomplete line read on EOF, since it doesn't typically matter anyway Returns NULL on EOF

        int i = 0;

        try {
            for (;;) {
                int result;

                result = inStream.read();

                if (result < 0) {
                    return null;
                }

                if (ctrlZ && result == 0x1a) {
                    break;
                } else if (result == '\r" || result == '\n") {
                    if (i == 0) {
                        // Skip leading cr/lf
                        continue;
                    } else {
                        break;
                    }
                }

                buffer[i++] = (byte)result;
            }
        } catch (IOException ex) {
            return null;
        } catch (IndexOutOfBoundsException ex) {
            System.err.println("ATChannel: buffer overflow");
        }

        try {
            return new String(buffer, 0, i, "US-ASCII");
        } catch (UnsupportedEncodingException ex) {
            System.err.println("ATChannel: implausable UnsupportedEncodingException");
            return null;
        }
    
java.lang.StringgetNextLineCtrlZ()

        return getNextLine(true);