Wednesday, February 15, 2012

[Resolved] Do not use APIs from sun.* packages (WAS Upgrade)

This is a short note for my WAS upgrade project V6.0 to V7.0

Recommendation by the WebSphere Application Migration Tool:
Do not use APIs from sun.* packages

Package: sun.misc.BASE64Encoder

*** Code changes as below:

Before
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;


String text = "Hello!";
// Encode
sun.misc.BASE64Encoder base64encoder = new sun.misc.BASE64Encoder();
String encodedText = base64encoder.encode(text.getBytes());
                          
// Decode
sun.misc.BASE64Decoder base64decoder = new sun.misc.BASE64Decoder();
byte[] output= base64decoder.decodeBuffer(encodedText);

After
import org.apache.commons.codec.binary.Base64;

String text = "Hello!";
                          
// Encode (static method)
String encodedText = Base64.encodeBase64String(text.getBytes());
                          
// Decode (static method)
byte[] output= Base64.decodeBase64(encodedText);

No comments:

Post a Comment