Reads the entire file line by line and invoke a callback for each line.

@param aLineConsumer
The consumer that is invoked for every line. May not be
<code>null</code>.
@throws IOException
if bad things happen during the read
339702
public void readAll (@Nonnull final Consumer <? super ICommonsList <String>> aLineConsumer) throws IOException
  {
    while (m_bHasNext)
    {
      final ICommonsList <String> aNextLineAsTokens = readNext ();
      if (aNextLineAsTokens != null)
        aLineConsumer.accept (aNextLineAsTokens);
    }
  }
569538
private Entry readEntry(BufferedReader reader) throws IOException {
    for (String line = reader.readLine(); line != null; line = reader.readLine()) {
      Entry entry = parseEntry(line);
      if (entry != null) {
        return entry;
      }
    }
    return null;
  }
775888
public static <T, C extends Collection<T>> void
    ifNotNullOrEmptyConsume(C collection, Consumer<C> consumer) {
        JMOptional.getOptional(collection).ifPresent(consumer);
    }
746384
public void load(InputStream in) throws IOException {

	BufferedReader input = IOUtil.toBufferedReader(new InputStreamReader(in));
	String read;
	Map section = null;
	String sectionName;
	while ((read = input.readLine()) != null) {
	    if (read.startsWith(";") || read.startsWith("#")) {
		continue;
	    }
	    else if (read.startsWith("[")) {
		// new section
		sectionName = read.substring(1, read.indexOf("]")).trim().toLowerCase();
		section = getSectionEL(sectionName);
		if (section == null) {
		    section = newMap();
		    sections.put(sectionName, section);
		}
	    }
	    else if (read.indexOf("=") != -1 && section != null) {
		// new key
		String key = read.substring(0, read.indexOf("=")).trim().toLowerCase();
		String value = read.substring(read.indexOf("=") + 1).trim();
		section.put(key, value);
	    }
	}

    }
133284
@Override
    public void readExternal(PofReader reader) throws IOException {
        factory  = (Factory<List<E>>) reader.readObject(0);
        delegate = factory.create();
        reader.readCollection(1, delegate);
    }
1167787
public Reader getReader() throws IOException {
        if (this.charset != null) {
            return new InputStreamReader(this.resource.getInputStream(), this.charset);
        } else if (this.encoding != null) {
            return new InputStreamReader(this.resource.getInputStream(), this.encoding);
        } else {
            return new InputStreamReader(this.resource.getInputStream());
        }
    }
50985
public void readExternal(PofReader reader)
            throws IOException {
        name = reader.readString(0);
        last = reader.readLong(1);
    }
290961
@Override
  public void consume(SerializableConsumer<R> consumer) {
    checkNotNull(consumer, "consumer cannot be null");

    ConsumerStreamlet<R> consumerStreamlet = new ConsumerStreamlet<>(this, consumer);
    addChild(consumerStreamlet);
  }
889511
public void readExternal(PofReader reader) throws IOException {
        super.readExternal(reader);
        language = reader.readString(10);
        init();
    }
1065118
private long readLines(final RandomAccessFile reader) throws IOException {
        final ByteArrayOutputStream lineBuf = new ByteArrayOutputStream(64);
        long pos = reader.getFilePointer();
        long rePos = pos; // position to re-read
        int num;
        boolean seenCR = false;
        // FIXME replace -1 with EOF when we're merging back into commons-io
        while ((num = reader.read(this.inbuf)) != -1) {
            for (int i = 0; i < num; i++) {
                final byte ch = this.inbuf[i];
                switch (ch) {
                    case '\n':
                        seenCR = false; // swallow CR before LF
                        this.listener.handle(new String(lineBuf.toByteArray(), this.cset));
                        lineBuf.reset();
                        rePos = pos + i + 1;
                        break;
                    case '\r':
                        if (seenCR) {
                            lineBuf.write('\r');
                        }
                        seenCR = true;
                        break;
                    default:
                        if (seenCR) {
                            seenCR = false; // swallow final CR
                            this.listener.handle(new String(lineBuf.toByteArray(), this.cset));
                            lineBuf.reset();
                            rePos = pos + i + 1;
                        }
                        lineBuf.write(ch);
                }
            }
            pos = reader.getFilePointer();
        }
        IOUtils.closeQuietly(lineBuf); // not strictly necessary
        reader.seek(rePos); // Ensure we can re-read if necessary
        return rePos;
    }
305313
public void run() {
        logger.trace("BlockingConsumer " + this + " starting data processing");

        int length;
        char cs[] = new char[256];
        Reader reader = pair.getReader();

        while (!stopRequested && !foundEOF) {
            try {
                logger.trace("BlockingConsumer " + this + " reading from reader");
                length = reader.read(cs); // blocking
            } catch (IOException ioe) {
                // The reader most likely closed on us.
                logger.warn("Caught an exception while reading: " + ioe);
                logger.debug("Assuming EOF");
                foundEOF = true;
                break;
            }

            if (length == -1) { //EOF
                logger.debug("BlockingConsumer " + this + " detected EOF");
                logger.trace("Remaining buffer: " + buffer.toString());
                foundEOF = true;
                break;
            }

            // don't modify the buffer while processing is happening
            // written as while loop to prevent spurious interrupts
            logger.trace("BlockingConsumer " + this + " waiting for synchronized access before appending");
            synchronized(this) { // this could be just before notify, I think
                if (logger.isDebugEnabled()) {
                    logger.debug("BlockingConsumer " + this + " appending " + length + " characters to the buffer");

                    // TODO: this replace operation is done a few places, perhaps utility class?
                    String print = new String(cs, 0, length);
                    print = print.replaceAll("\n", "\\\\n");
                    print = print.replaceAll("\r", "\\\\r");
                    logger.debug("Adding to buffer: " + print);

                    StringBuffer sb = new StringBuffer();
                    for (int i = 0; i < length; i++)
                        sb.append("," + ((int) cs[i]) );
                    logger.trace("Codes: " + sb.toString());
                }
                buffer.append(cs, 0, length); // thread safe

                /**
                 * TODO Trim down buffer.  This current method won't work if a resume comes in, since it's offset
                 * will be invalid once this delete method runs
                 *
                 * // since we only added one char, we should only have to remove one
                 * if (buffer.length() > BUFFERMAX)
                 *     buffer.delete(0, BUFFERMAX - buffer.length());
                 */

                logger.trace("BlockingConsumer " + this + " notifying listeners of buffer change");
                notify(); // seeing that we read something, wake people up

                // We explicitly call this after appending to the
                // buffer, just in case one of the BufferChangeLoggers
                // accidentally modifies the character buffer.
                notifyBufferChange(cs, length);
            } // end synchronized(this)
        } // end while loop

        logger.trace("BlockingConsumer " + this + " notifying listeners upon ceasing");
        synchronized(this) {
            notify();
        }

        if (stopRequested) {
            logger.debug("BlockingConsumer " + this + " stop requested");
            pair.close();
        }

        if (foundEOF)
            logger.debug("BlockingConsumer " + this + " found EOF to stop while loop");
    }

    /**
     * TODO: what if something came in between when we last checked and
     *       when this method is called
     *
     * @param timeout timeout in milliseconds
     */
    public void waitForBuffer(long timeout) {
        if (foundEOF) {
            logger.trace("BlockingConsumer " + this + " wanted to wait for buffer but found EOF");
            return;
        }

        logger.trace("BlockingConsumer " + this + " ynching on this to wait");
        logger.trace("BlockingConsumer " + this + " waiting for synchronized access before waiting");
        synchronized(this) {
            try {
                if (timeout > 0) {
                    logger.trace("BlockingConsumer " + this + " waiting for " + timeout + " msec for some additional event");
                    wait(timeout);
                } else {
                    logger.trace("BlockingConsumer " + this + " waiting forever for some additional event");
                    wait();
                }
            } catch (InterruptedException ie) {
                logger.trace("BlockingConsumer " + this + " woken up while waiting for buffer");
            }
        }
    }

    /**
     * TODO
     *
     * @return TODO
     */
    public String pause() {
        // TODO mark offset, so that it can be trimmed by resume coming in later
        String currentBuffer;
        currentBuffer = buffer.toString();
        return currentBuffer;
    }

    /**
     * Resume processing from the specified offset.
     *
     * @param offset the offset into the buffer (1-indexed) from which
     *               to start
     */
    public void resume(int offset) {
        if (offset < 0)
            return;

        synchronized(this) {
            logger.trace("BlockingConsumer " + this + " moving buffer up by " + offset);
            StringBuffer smaller = buffer.delete(0, offset); // + 1
        }
    }

    /**
     * A method to test the <code>BlockingConsumer</code> class independently.
     *
     * @param args command line arguments (none used)
     */
    public static void main(String args[]) throws Exception {
        final StringBuffer buffer = new StringBuffer("The lazy fox");

        Thread t1 = new Thread() {
            public void run() {
                synchronized(buffer) {
                    buffer.delete(0,4);
                    buffer.append(" in the middle");
                    System.err.println("Middle");
                    try {
                        Thread.sleep(4000);
                    } catch (Exception e) {}
                    buffer.append(" of fall");
                    System.err.println("Fall");
                }
            }
        };

        Thread t2 = new Thread() {
            public void run() {
                try {
                    Thread.sleep(1000);
                } catch (Exception e) {}
                buffer.append(" jump over the fence");
                System.err.println("Fence");
            }
        };

        t1.start();
        t2.start();

        t1.join();
        t2.join();

        System.err.println(buffer);
    }
}
872019
public void read(BufferedReader reader) throws Exception {
		String line;

		clear();

		while ((line = reader.readLine()) != null) {
			line = line.trim();
			// comment?
			if (line.startsWith("#"))
				continue;
			add(line);
		}

		reader.close();
	}
309444
public void read(ByteCodeParser in)
    throws IOException
  {
    int length = in.readInt();
    
    int exnCount = in.readShort();

    for (int i = 0; i < exnCount; i++) {
      int index = in.readShort();

      if (index == 0) {
        _methods.add(null);
      }
      
      // _methods.add(in.getConstantPool().getClass(index).getName());
    }
  }
331909
private void read(final ActionCollector collector) throws IOException
   {
      if (!dir.fileExists(REDO_LOG))
      {
         return;
      }
      InputStream in = new IndexInputStream(dir.openInput(REDO_LOG));
      BufferedReader reader = null;
      try
      {
         reader = new BufferedReader(new InputStreamReader(in));
         String line;
         while ((line = reader.readLine()) != null)
         {
            try
            {
               collector.collect(MultiIndex.Action.fromString(line));
            }
            catch (IllegalArgumentException e)
            {
               log.warn("Malformed redo entry: " + e.getMessage());
            }
         }
      }
      finally
      {
         if (reader != null)
         {
            try
            {
               reader.close();
            }
            catch (IOException e)
            {
               log.warn("Exception while closing redo log: " + e.toString());
            }
         }
         if (in != null)
         {
            try
            {
               in.close();
            }
            catch (IOException e)
            {
               log.warn("Exception while closing redo log: " + e.toString());
            }
         }
      }
   }
1359979
public static void readLines(InputStream in, Charset charset, LineHandler lineHandler) throws IORuntimeException {
		readLines(getReader(in, charset), lineHandler);
	}
578542
private String readLine(InputStream stream) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
        return reader.readLine();
    }
112172
public void readFrom(final InputStream in) throws IOException {
        pointer = 0;
        size = 0;
        int n;
        do {
            n = in.read(buffer, size, buffer.length - size);
            if (n > 0) {
                size += n;
            }
            resizeIfNeeded();
        } while (n >= 0);
    }