这是我的服务端的代码:
String imagePath="/home/shenlei/tupian/jiaofu.jpg";
File file =new File(imagePath);
FileInputStream inputstream = new FileInputStream(file);
OutputStream out = resp.getOutputStream();
//拷贝输出
byte[] buf = new byte[1024];
int count = 0;
while ((count =inputstream.read(buf)) >= 0) {
out.write(buf, 0, count);
}
inputstream.close();
out.close();
}
这是客户端的接受的代码:
// 取得图片字节流
HttpEntity httpEntity = response.getEntity();
InputStream is = httpEntity.getContent();
bitmap = BitmapFactory.decodeStream(is);
is.close();
但是获取的图像没有现实出来:
ImageView image = (ImageView) findViewById(R.id.detail_img);
image.setImageBitmap(HttpUtil.bitmap);
这是log
07-28 12:52:13.861: D/libc(25884): [NET] getaddrinfo+,hn 13(0x3139322e313638),sn(),family 0,flags 4
07-28 12:52:13.861: D/libc(25884): [NET] getaddrinfo-, SUCCESS
07-28 12:52:13.861: D/libc(25884): [NET] getaddrinfo+,hn 13(0x3139322e313638),sn(),family 0,flags 4
07-28 12:52:13.861: D/libc(25884): [NET] getaddrinfo-, SUCCESS
07-28 12:52:13.861: D/libc(25884): [NET] getaddrinfo+,hn 13(0x3139322e313638),sn(),family 0,flags 4
07-28 12:52:13.861: D/libc(25884): [NET] getaddrinfo-, SUCCESS
07-28 12:52:13.871: I/global(25884): call createSocket() return a new socket.
07-28 12:52:13.871: D/libc(25884): [NET] getaddrinfo+,hn 13(0x3139322e313638),sn(),family 0,flags 4
07-28 12:52:13.871: D/libc(25884): [NET] getaddrinfo-, SUCCESS