Android examples for java.lang:Character
Convert to and from ASCII
import java.io.UnsupportedEncodingException; public class Main{ public static String fromASCII(byte[] bytes) { try {//from www . ja v a 2 s .c o m return new String(bytes, "US-ASCII"); } catch (UnsupportedEncodingException e) { /* Should never happen. */ throw new RuntimeException(e); } } public static String fromASCII(byte[] bytes, int offset, int len) { try { return new String(bytes, offset, len, "US-ASCII"); } catch (UnsupportedEncodingException e) { /* Should never happen. */ throw new RuntimeException(e); } } }