code: public void writeGeometry(Geometry g) throws IOException {
          if(type == null) {
              throw new IllegalStateException("Header must be written before writeGeometry");
          }
          if(bounds != null) {
              if(g != null) {
                  bounds.expandToInclude(g.getEnvelopeInternal());
              }
          } else {
              bounds = g.getEnvelopeInternal();
          }
  		int length;
  		if (g == null) {
  			length = 4;
  		} else {
  			length = handler.getLength(g);
  		}
  
  		length /= 2;
  
  		shapeBuffer.order(ByteOrder.BIG_ENDIAN);
  		shapeBuffer.putInt(++cnt);
  		shapeBuffer.putInt(length);
  		shapeBuffer.order(ByteOrder.LITTLE_ENDIAN);
  		if (g == null) {
  			shapeBuffer.putInt(0);
  		} else {
  			shapeBuffer.putInt(type.id);
  			handler.write(shapeBuffer, g);
  		}
  
  		// write to the shx
  		indexBuffer.putInt(offset);
  		indexBuffer.putInt(length);
  		offset += length + 4;
  	}
docs: Write a single Geometry to this shapefile. The Geometry must be
  compatable with the ShapeType assigned during the writing of the headers.
  
  @param g
  @throws java.io.IOException