String s = "This is text"; char[] bytes = s.getBytes(); System.out.println( Arrays.toString( bytes ) );Output:
[84, 104, 105, 115, 32, 105, 115, 32, 116, 101, 120, 116]Note: In method java.lang.String.getBytes() you can optionally set default charset.
No comments:
Post a Comment