public static byte[] getBytes(final Writable w) throws IOException {
    if (w == null) {
      throw new IllegalArgumentException("Writable cannot be null");
    }
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    DataOutputStream out = new DataOutputStream(byteStream);
    try {
      w.write(out);
      out.close();
      out = null;
      return byteStream.toByteArray();
    } finally {
      if (out != null) {
        out.close();
      }
    }
  }
Get the Writable's contents as a byte array
@param w writable
@return The bytes of <code>w</code> gotten by running its
        {@link Writable#write(java.io.DataOutput)} method.
@throws IOException e
@see #getWritable(byte[], Writable)
hbase-client/src/main/java/org/apache/hadoop/hbase/util/Writables.java