V
Vallabha
Hello All,
I am trying to understand how BASE64Encoder() and BASE64Decoder()
work. I wrote a small sample for that:
==========================================
import java.io.IOException;
import java.util.*;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class Base64 {
public static void main(String[] args)throws IOException{
String a = new String("TEST");
System.out.println("Original string: " + a);
String encode = new sun.misc.BASE64Encoder().encode(a.getBytes());
System.out.println("Encoded String: " + encode);
byte[] decode = new sun.misc.BASE64Decoder().decodeBuffer(encode);
System.out.println("Decoded String: " + decode);
}
}
========================================
Original string: TEST
Encoded String: VEVTVA==
Decoded String: [B@addbf1
=========================================
Here I was expecting the original string after the decoding. However
decoded string is different from the original one. Now how do I get
back my original string.
Any clue on this will be of great help.
Thanks
-Vallabha
I am trying to understand how BASE64Encoder() and BASE64Decoder()
work. I wrote a small sample for that:
==========================================
import java.io.IOException;
import java.util.*;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class Base64 {
public static void main(String[] args)throws IOException{
String a = new String("TEST");
System.out.println("Original string: " + a);
String encode = new sun.misc.BASE64Encoder().encode(a.getBytes());
System.out.println("Encoded String: " + encode);
byte[] decode = new sun.misc.BASE64Decoder().decodeBuffer(encode);
System.out.println("Decoded String: " + decode);
}
}
========================================
Original string: TEST
Encoded String: VEVTVA==
Decoded String: [B@addbf1
=========================================
Here I was expecting the original string after the decoding. However
decoded string is different from the original one. Now how do I get
back my original string.
Any clue on this will be of great help.
Thanks
-Vallabha