当前位置: 技术问答>java相关
com.ibm.util.base64 是再那個包里面﹖
来源: 互联网 发布时间:2015-03-18
本文导语: 為什么不找不到阿﹖請告訴我﹐謝謝﹗ | public class Base64 { /** decode a Base 64 encoded String. * String to byte conversion * This method uses a naive String to byte interpretation, it sim...
為什么不找不到阿﹖請告訴我﹐謝謝﹗
|
public class Base64
{
/** decode a Base 64 encoded String.
*
*
*
*/
public static String decode(String encoded)
{
StringBuffer sb = new StringBuffer();
int maxturns;
//work out how long to loop for.
if(encoded.length() % 3 == 0)
maxturns = encoded.length();
else
maxturns = encoded.length() + (3 - (encoded.length() % 3));
//tells us whether to include the char in the unencode
boolean skip;
//the unencode buffer
byte[] unenc = new byte[4];
byte b;
for(int i = 0, j = 0; i
{
/** decode a Base 64 encoded String.
*
String to byte conversion
* This method uses a naive String to byte interpretation, it simply gets each
* char of the String and calls it a byte.
*
Since we should be dealing with Base64 encoded Strings that is a reasonable
* assumption.
*
End of data
* We don't try to stop the converion when we find the "=" end of data padding char.
* We simply add zero bytes to the unencode buffer.
*/
public static String decode(String encoded)
{
StringBuffer sb = new StringBuffer();
int maxturns;
//work out how long to loop for.
if(encoded.length() % 3 == 0)
maxturns = encoded.length();
else
maxturns = encoded.length() + (3 - (encoded.length() % 3));
//tells us whether to include the char in the unencode
boolean skip;
//the unencode buffer
byte[] unenc = new byte[4];
byte b;
for(int i = 0, j = 0; i