fork(7) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.Base64;
  7.  
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args)
  13. {
  14. try{
  15. String str = new String("Apple@2106".getBytes(), "UTF-8");
  16. byte[] bytesEncoded = Base64.getDecoder().decode(str);
  17. System.out.println("ecncoded value is " + new String(bytesEncoded ));
  18.  
  19. // Decode data on other side, by processing encoded data
  20. byte[] valueDecoded= Base64.getEncoder().encode(bytesEncoded );
  21. System.out.println("Decoded value is " + new String(valueDecoded));
  22. } catch(Exception e){
  23. System.out.println(e.getMessage());
  24. e.printStackTrace();
  25. }
  26. }
  27. }
Success #stdin #stdout #stderr 0.1s 320512KB
stdin
Standard input is empty
stdout
Illegal base64 character 40
stderr
java.lang.IllegalArgumentException: Illegal base64 character 40
	at java.util.Base64$Decoder.decode0(Base64.java:714)
	at java.util.Base64$Decoder.decode(Base64.java:526)
	at java.util.Base64$Decoder.decode(Base64.java:549)
	at Ideone.main(Main.java:16)