code: public SF next() throws IOException {
  
  		int remaining = afpData.remaining();
  		if(remaining == 0) return null;
  		if(remaining < 9) throw new IOException("trailing garbage at the end of file.");
  		
  		byte buf;
  		long thisOffset = afpData.position();
  
  		try {
  			if(leadingLengthBytes == -1) {
  				// we haven't tested for mvs download leading length bytes
  				// we don't need them and don't want to see them
  				int leadingLength = 0;
  				do {
  					buf = afpData.get();
  					leadingLength++;
  				} while((buf & 0xff) != 0x5a && afpData.remaining() > 0 && leadingLength < 5);
  				
  				leadingLengthBytes = leadingLength-1;
  								
  			} else {
  				if(leadingLengthBytes > 0) afpData.position(afpData.position() + leadingLengthBytes); // just throw away those
  				buf = afpData.get();
  			}
  			
  			if((buf & 0xff) != 0x5a)
  				throw new IOException("cannot find 5a magic byte");
  			data[0] = buf;
  			
  			buf = afpData.get();
  			data[1] = buf;
  			length = (byte) buf << 8;
  
  			buf = afpData.get();
  			data[2] = (byte) (buf & 0xff);
  			length |= (byte) buf & 0xff;
  			
  			length -= 2;
  			
  			if(length + 3 > data.length)
  				throw new IOException("length of structured field is too large: "+length);
  					
  			afpData.get(data, 3, length);
  		} catch (BufferUnderflowException e) {
  			return null; // FIXME could also be an error
  		}
  		
  		SF sf = factory.sf(data, 0, getLength() + 2);
  		sf.setLength(length + 3);
  		sf.setOffset(thisOffset);
  		sf.setNumber(number++);
  		
  		return sf;
  	}
docs: Reads a new structured field from the mapped file.
  This method is not thread-safe!
  
  @return structured field or null if end of input.
  @throws IOException