public int read()
		throws IOException
	{
		int i;

		if (readLen > readPos)	{	// use buffer if buffer is not at end
			i = buffer[readPos];
			readPos++;
			return i;
		}
		
		if (eof)
			return EOF;

		// read one character from input
		i = (reader != null) ? reader.read() : inputStream.read();
		
		// recognize end of input
		if (i == -1)	{
			eof = true;
			
			try	{
				if (reader != null)
					reader.close();
				else
					inputStream.close();
			}
			catch (IOException e)	{
			}
		}
		else	{
			readOffset++;
			convertInput(i);	// input hook for subclasses
			
			if (buffering)	// store character if in buffering state
				storeRead(i);
			else
				readPos = readLen = 0;
		}
		
		return i;
	}