src/org/kocakosm/pitaya/charset/UTF8.java
public static byte[] encode(String str)
	{
		CharsetEncoder encoder = Charsets.UTF_8.newEncoder();
		try {
			ByteBuffer out = encoder.encode(CharBuffer.wrap(str));
			byte[] bytes = new byte[out.limit()];
			out.get(bytes);
			return bytes;
		} catch (CharacterCodingException ex) {
			throw new IllegalArgumentException(ex);
		}
	}
public static byte[] encode(String str)
	{
		CharsetEncoder encoder = Charsets.UTF_8.newEncoder();
		try {
			ByteBuffer out = encoder.encode(CharBuffer.wrap(str));
			byte[] bytes = new byte[out.limit()];
			out.get(bytes);
			return bytes;
		} catch (CharacterCodingException ex) {
			throw new IllegalArgumentException(ex);
		}
	}
public static byte [ ] encode ( String str ) { CharsetEncoder encoder = Charsets . UTF_8 . newEncoder ( ) ; try { ByteBuffer out = encoder . encode ( CharBuffer . wrap ( str ) ) ; byte [ ] bytes = new byte [ out . limit ( ) ] ; out . get ( bytes ) ; return bytes ; } catch ( CharacterCodingException ex ) { throw new IllegalArgumentException ( ex ) ; } }
Returns the UTF-8 encoding of the given {@code String}.

@param str the {@code String} to encode.

@return the UTF-8 encoding of the given {@code String}.

@throws NullPointerException if {@code str} is {@code null}.
@throws IllegalArgumentException if {@code str} can't be encoded into
UTF-8.
Returns the UTF - 8 encoding of the given { @code String } .