Code example for EOFException

0
	 
	public int readByte(InputStream in) throws IOException {
		int r = in.read();
 
		if (r == -1) {
			throw new EOFException("EOF reached");
		} 
		 
		if (unsigned) {
			return r & 0xFF;
		} else { 
			return (int)((byte)r);
		} 
	} 
 
	@Override 
	public Byte read(InputStream in) throws IOException {
		return (byte)readByte(in);
	} 
	 
	public static int writeByte(byte[] buf, int pos, byte i) {