public byte[] toBytes(){
  ByteBuffer geometryByteBuffer=data.toByteBuffer();
  geometryByteBuffer.rewind();
  int size=12 + geometryByteBuffer.capacity();
  ByteBuffer buf=ByteBuffer.allocate(size);
  buf.order(ByteOrder.LITTLE_ENDIAN);
  buf.rewind();
  buf.putInt(ByteSwapper.swap(recordNumber));
  buf.putInt(ByteSwapper.swap(contentLength));
  buf.putInt(getIntFromShapeType(shapeType));
  byte[] bytes=geometryByteBuffer.array();
  for (int i=0; i < bytes.length; i++) {
    buf.put(bytes[i]);
  }
  return buf.array();
}

public byte [ ] toBytes ( ) { ByteBuffer geometryByteBuffer = data . toByteBuffer ( ) ; geometryByteBuffer . rewind ( ) ; int size = 12 + geometryByteBuffer . capacity ( ) ; ByteBuffer buf = ByteBuffer . allocate ( size ) ; buf . order ( ByteOrder . LITTLE_ENDIAN ) ; buf . rewind ( ) ; buf . putInt ( ByteSwapper . swap ( recordNumber ) ) ; buf . putInt ( ByteSwapper . swap ( contentLength ) ) ; buf . putInt ( getIntFromShapeType ( shapeType ) ) ; byte [ ] bytes = geometryByteBuffer . array ( ) ; for ( int i = 0 ; i < bytes . length ; i ++ ) { buf . put ( bytes [ i ] ) ; } return buf . array ( ) ; }
this is used by the shapefile class to get convert the current data contained in this object into a bytebuffer than can then be written to disc .
