Here you can find the source of getBytes(final String data, String charset)
public static byte[] getBytes(final String data, String charset)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; public class Main { public static byte[] getBytes(final String data, String charset) { if (data == null) { throw new IllegalArgumentException("data may not be null"); }/*from w ww. ja v a2 s .c om*/ if (charset == null || charset.length() == 0) { throw new IllegalArgumentException( "charset may not be null or empty"); } try { return data.getBytes(charset); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException(String.format( "Unsupported encoding: %s", charset)); } } }