Here you can find the source of getBytes(String str)
Parameter | Description |
---|---|
str | String |
public static byte[] getBytes(String str)
//package com.java2s; public class Main { /**// www . j a v a2 s . c o m * Should always be able convert to/from UTF-8, so encoding exceptions are converted to an Error to avoid adding * throws declarations in lots of methods. * @param str String * @return utf8 bytes * @see String#getBytes() */ public static byte[] getBytes(String str) { try { return str.getBytes("UTF8"); } catch (java.io.UnsupportedEncodingException e) { throw new Error("String to UTF-8 conversion failed: " + e.getMessage()); } } }