/** * Encodes a <code>Geometry</code> into a WKB representation using the specified byte-order. * * @param geom The <code>Geometry</code> to be encoded as WKB. * @param wbo The WKB byte order, either {@link ByteOrder#XDR XDR} or {@link ByteOrder#NDR NDR} * @return A buffer of bytes that contains the WKB-encoded <code>Geometry</code>. */ public ByteBuffer encode(Geometry geom, ByteOrder wbo) { ByteBuffer output = ByteBuffer.allocate(calculateSize(geom, true)); if (wbo != null) { output.setWKBByteOrder(wbo); } writeGeometry(geom, output); output.rewind(); return output; }
public static void main(String[] args) throws Exception { String fromFileName = args[0]; String toFileName = args[1]; FileChannel in = new FileInputStream(fromFileName).getChannel(); FileChannel out = new FileOutputStream(toFileName).getChannel(); ByteBuffer buff = ByteBuffer.allocate(32 * 1024); while (in.read(buff) > 0) { buff.flip(); out.write(buff); buff.clear(); } in.close(); out.close(); }