Here you can find the source of utf8Encode(final String value)
Parameter | Description |
---|---|
value | to UTF-8 encode |
public static byte[] utf8Encode(final String value)
//package com.java2s; /*// ww w .j a v a 2 s .com $Id$ Copyright (C) 2003-2012 Virginia Tech. All rights reserved. SEE LICENSE FOR MORE INFORMATION Author: Middleware Services Email: middleware@vt.edu Version: $Revision$ Updated: $Date$ */ import java.nio.charset.Charset; public class Main { /** UTF-8 character set. */ private static final Charset UTF8_CHARSET = Charset.forName("UTF-8"); /** * This will convert the supplied value to a UTF-8 encoded byte array. Returns * null if the string cannot be encoded. * * @param value to UTF-8 encode * * @return UTF-8 encoded value */ public static byte[] utf8Encode(final String value) { return value != null ? value.getBytes(UTF8_CHARSET) : null; } }