Java tutorial
//package com.java2s; // and/or modify it under the terms of the GNU General Public License import java.io.UnsupportedEncodingException; public class Main { public static byte[] getBytes(final String value) { try { if (value == null) { return new byte[0]; } return value.getBytes("ASCII"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage()); } } }