Here you can find the source of getBytes(String str)
Parameter | Description |
---|---|
str | a parameter |
public static byte[] getBytes(String str)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; public class Main { /**/*from ww w . ja va 2 s . c om*/ * Get the bytes with UTF-8 * @param str * @return */ public static byte[] getBytes(String str) { if (str == null) { return null; } try { return str.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; } }