Here you can find the source of getUTF8Bytes(String str)
public static final byte[] getUTF8Bytes(String str)
//package com.java2s; /**/* w w w . j a v a 2 s . c o m*/ * Licensed to LGPL v3. */ import java.io.UnsupportedEncodingException; import java.util.logging.Level; import java.util.logging.Logger; public class Main { private static final Logger logger = Logger.getLogger("util"); public static final byte[] getUTF8Bytes(String str) { byte[] bytes = null; try { bytes = str.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { logger.log(Level.WARNING, "UTF-8 decoding error, continue by using default instead", e); bytes = str.getBytes(); } return bytes; } }