Java UTF8 From getUTF8Bytes(String str)

Here you can find the source of getUTF8Bytes(String str)

Description

get UTF Bytes

License

LGPL

Declaration

public static final byte[] getUTF8Bytes(String str) 

Method Source Code

//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;
    }
}

Related

  1. getUTF8Bytes(String data)
  2. getUtf8Bytes(String s)
  3. getUTF8Bytes(String s)
  4. getUTF8Bytes(String s)
  5. getUtf8Bytes(String s)
  6. getUtf8Bytes(String str)
  7. getUtf8Bytes(String str)
  8. getUTF8Stream(String s)
  9. getUTF8String(byte[] bytes)