public static byte[] toUtf(String s) throws UTFDataFormatException {
  try {
    OptimizedByteArrayOutputStream bout=new OptimizedByteArrayOutputStream(s.length());
    DataOutput dout=new DataOutputStream(bout);
    dout.writeUTF(s);
    return bout.toByteArray();
  }
 catch (  UTFDataFormatException e) {
    throw e;
  }
catch (  IOException e) {
    throw new AssertionError(e);
  }
}

public static byte [ ] toUtf ( String s ) throws UTFDataFormatException { try { OptimizedByteArrayOutputStream bout = new OptimizedByteArrayOutputStream ( s . length ( ) ) ; DataOutput dout = new DataOutputStream ( bout ) ; dout . writeUTF ( s ) ; return bout . toByteArray ( ) ; } catch ( UTFDataFormatException e ) { throw e ; } catch ( IOException e ) { throw new AssertionError ( e ) ; } }
returns a byte array containing the utf encoding of the given string .
