我有关于发送和获取图像的编码数据的问题。首先我有图像作为字符串Base64编码类型,这串具有一个值,如以下: ... d/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4pLSwzOko + MZZ ...编码字符串的http get/post
,如果我现在再次进行解码,并且如果我使用BitmapFactory以适应在imageview这就是所有正确的形象是好的。
byte[] bytes= stream.toByteArray();
imagestr=Base64.encodeBytes(bytes).toString();
//If i code below it is working
byte[] decode = Base64.decode(imagestr);
decoded = BitmapFactory.decodeByteArray(decode, 0, decode.length);
//If i send to the server and handle it in servlet file
String pic = request.getParameter("p");
byte[] servdec = Base64.decode(pic);
//and if i use the servdec to output a image file file is corrupted.
//I noticed the pic and imagestr are different
//imagestr = **...D/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4pLSwzOko+MzZ...**
//pic = **...D/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4pLSwzOko MzZ...**
//pic has no + sign.
我使用了replaceAll,但仅限于这种情况。它可能会导致更多的问题。那么有没有可以咨询感谢你的答案...
嗨任何解决方案,这个字符串在谈到这个功能,这个功能servlet将处理这个后PIC!石化公司+登录该功能
公共字符串uuidfaceid(UUID字符串,字符串faceid,字符串名称,字符串PIC){
URL url = null;
try {
url = new
URL( “HTTP://” + Constants.SERVER_NAME + Constants.SERVER_PORT + “/ MeetInTouch/UF” +“ ? uuid =“+ uuid +”& faceid =“+ faceid +”& name =“+ name +”& pic =“+ pic);
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
URLConnection ucon = null;
try {
ucon = url.openConnection();
} catch (IOException e1) {
e1.printStackTrace();
}
try {
ucon.connect();
} catch (IOException e1) {
e1.printStackTrace();
}
看起来像逃逸的问题 - 空间与'+''为应用程序/ x-WWW的形式encoded'取代。在发送之前,你可能应该避开字符串 - 告诉我们你是如何做到的。 – 2013-03-16 19:20:40