用json在java和C#之间传递base64的问题。。。

记录下。。唉。。。。

java代码:

导入这个

commons-codec-1.8.jar (下载链接: http://files.cnblogs.com/files/gaocong/jar%E5%8C%85.rar)
java后台方法 InputStream in
= null; byte[] data = null; //读取图片字节数组 try { in = new FileInputStream(imgFilePath); data = new byte[in.available()]; in.read(data); in.close(); } catch (IOException e) { e.printStackTrace(); } //对字节数组Base64编码 return new String(Base64.encodeBase64(data));//返回Base64编码过的字节数组字符串

然后在c#中解码

 //字符串转流
                byte[] bt = Convert.FromBase64String(m_l.BinaryImg);
原文地址:https://www.cnblogs.com/gaocong/p/4938921.html