package org.hwo.text; public class LineReader { private char[] buffer; private int position; public LineReader() { position = 0; } public LineReader(String line) { position = 0; setText(line); } public void setText(String text){ position = 0; buffer = (text == null) ? new char[0] : text.toCharArray(); } public String getText(){ return new String(buffer); } public char peek(){ return buffer[position]; } public char peek(int offset){ return buffer[position + offset]; } public char read(){ return buffer[position++]; } public void seek(int pos){ position = pos; } public boolean endOfLine(){ return (position >= buffer.length); } }