private StringBuilder read ( int n ) throws IOException { // Input stream finished? boolean eof = false ; // Read that many. final StringBuilder s = new StringBuilder ( n ) ; while ( s . length ( ) < n && ! eof ) { // Always get from the pushBack buffer. if ( pushBack . length ( ) == 0 ) { // Read something from the stream into pushBack. eof = readIntoPushBack ( ) ; } // Pushback only contains deliverable codes. if ( pushBack . length ( ) > 0 ) { // Grab one character s . append ( pushBack . charAt ( 0 ) ) ; // Remove it from pushBack pushBack . deleteCharAt ( 0 ) ; } } return s ; }
Read n characters .