ITeye博客

BASE64转码成字符串和字符串转化为bytebuffer

tomhat · 2010-12-16 16:10 · java · 编程语言 · Markdown

import sun.misc.BASE64Decoder; import java.nio.ByteBuffer; public class Base64Utils { public static String getFromBASE64(String s) { if (s == null) return null; BASE64Decoder decoder = new BASE64Decoder(); try { byte b = decoder.decodeBuffer(s); return new String(b, "UTF-8"); } catch (Exception e) { return null; } } public static ByteBuffer getFromBASE64byte(String s) { if (s == null) return null; BASE64Decoder decoder = new BASE64Decoder(); try {

		return decoder.decodeBufferToByteBuffer(s);//decoder.decodeBuffer(s);
	} catch (Exception e) {
		return null;
	}
}

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。