fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone {
  9.  
  10. public static void main (String[] args) throws java.lang.Exception {
  11.  
  12. final String input = "\\xF0\\x9F\\x87\\xB7\\xF0\\x9F\\x87\\xBA";
  13. final String[] inputItems = input.trim().split("\\\\x");
  14.  
  15. final byte[] test = new byte[inputItems.length];
  16. test[0] = (byte) 0xF0;
  17. test[1] = (byte) 0x9F;
  18. test[2] = (byte) 0x87;
  19. test[3] = (byte) 0xB7;
  20. test[4] = (byte) 0xF0;
  21. test[5] = (byte) 0x9F;
  22. test[6] = (byte) 0x87;
  23. test[7] = (byte) 0xBA;
  24.  
  25.  
  26. final byte[] emojiByte = new byte[inputItems.length];
  27. for (int i = 0; i < inputItems.length-1; i++) {
  28. emojiByte[i] = (byte) Integer.parseInt(inputItems[i+1].replace("0x", ""), 16);
  29. }
  30. System.out.println(Arrays.toString(test));
  31. System.out.println(Arrays.toString(emojiByte));
  32.  
  33. System.out.println(test);
  34. System.out.println(emojiByte);
  35.  
  36. }
  37. }
Success #stdin #stdout 0.09s 27772KB
stdin
Standard input is empty
stdout
[-16, -97, -121, -73, -16, -97, -121, -70, 0]
[-16, -97, -121, -73, -16, -97, -121, -70, 0]
[B@1540e19d
[B@677327b6