Mega Code Archive

 
Categories / Java Tutorial / Development
 

Convert string to UTF8 bytes

public class MainClass {   public static void main(String args[]) throws Exception {     String s = "0123456789";     byte ptext[] = s.getBytes("UTF8");     for (int i = 0; i < ptext.length; i++) {       System.out.print(ptext[i] + ",");     }   } }