关于图片在网络中的传输

最近学习中学习到关于c#  如何把图片用webservice传输  然后java 端接收保存,或者反之。。。

首先:要将图片转换成byte 

其次:要讲byte进行base64编码 (之前没有编码没有传输成功的) 

最后:java端接收到进行base64译码

下面贴出代码:

           c#端
            String imgpath = @"imgPath";
FileStream file = new FileStream(imgpath, FileMode.Open, FileAccess.Read);
byte[] byteArray = new byte[file.Length];
file.Read(byteArray, 0, byteArray.Length);
file.Close();
String strbaser64 = Convert.ToBase64String(byteArray);
java端
byte[] buffer = Base64.decode(bytes);
File file = new File(SDPATH + imagePath);

FileOutputStream fos = new FileOutputStream(file);

fos.write(buffer);

fos.flush();

fos.close();


如果有不不足处请大家多指点,谢谢

原文地址:https://www.cnblogs.com/gfqFighting/p/2349973.html