fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Idinahui{
  6.  
  7. public static void main (String[] args) throws java.lang.Exception{
  8. Idinahui idi = new Idinahui();
  9. //Console console = System.console();
  10. //String s = console.readLine("Enter text:");
  11. String s = "Idi nahui";
  12. idi.idinah(s);
  13. }
  14.  
  15. public void idinah(String s) throws java.lang.Exception {
  16. char[] charArray = s.toCharArray();
  17. int[] codes = new int[charArray.length];
  18. for (int i=0; i<charArray.length; i++){
  19. codes[i] = (int) charArray[i];
  20. }
  21. //why?
  22. byte[] b = new byte[codes.length];
  23. for (int i=0; i<codes.length; i++){
  24. b[i] = (byte) codes[i];
  25. }
  26. //because I can
  27. String idina = new String(b, "UTF-8");
  28. System.out.print(idina);
  29. }
  30.  
  31. }
Success #stdin #stdout 0.09s 320576KB
stdin
Standard input is empty
stdout
Idi nahui