FileDocCategorySizeDatePackage
ModelInterpreter.javaAPI DocAndroid 5.1 API16953Thu Mar 12 22:22:54 GMT 2015com.android.internal.telephony.test

LineReader

public class LineReader extends Object

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


      
    
        mInStream = 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 = mInStream.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;
                    }
                }

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

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

        return getNextLine(true);