入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

java base64 编码 解码, HTTP传送解决+号 问题,查询处理

创建时间:2015-01-13 投稿人: 浏览次数:108

java base64 编码 解码

public static void main(String[] args) throws Exception {

		String parm = "Title=不要这样额&Content=好好好好好";

		// BASE64Decoder
		String paramBase64 = new BASE64Encoder().encode(parm.getBytes("utf-8"));
		System.out.println("转base64:" + paramBase64);

		BASE64Decoder decoder = new BASE64Decoder();
		byte[] decoderStr = decoder.decodeBuffer(paramBase64);

		System.out.println("转码后:" + new String(decoderStr));


加号问题

titleBase64.replaceAll("[+]", "%2B")


sr = sr.replaceAll(" ", "").replaceAll(" ", "");


base64查询处理

String titleReturn = "";
		if (message.getTitle() != null) {
			titleReturn = message.getTitle();
			String baseTitle = new BASE64Encoder().encode(message.getTitle()
					.getBytes());
			if (baseTitle.contains("=")) {
				int index = baseTitle.indexOf("=");
				baseTitle = baseTitle.substring(0, index - 1);
			}

			message.setTitle(baseTitle);
		}


声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。