android和web 服务器之间传输图片和文字如何实现

android和web 服务器之间传输图片和文字怎么实现?
我先说下我的思路,我先把图片做Base64的编码,安卓端收到信息后做相应的解码。
 服务端源代码:
	@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletExceptionIOException {
req.setCharacterEncoding("UTF-8");
resp.setCharacterEncoding("UTF-8");
Bookdao bookdao = new BookdaoImpl();
List<Book> list = bookdao.findAllBook();
// 将内容拼接成相应格式的字符串,其中没一组之间用分号分割,每一项之间用逗号分割。图片读取其信息并采用
// Base64编码传输
String out = "";

for (Book book : list) {
String pic = "";
pic = book.getPic();
ImageOutput imageoutput = new ImageOutput("/home/shenlei/tupian/"
+ pic, resp);
String pictostring = imageoutput.GetImageStr();
out = out + pictostring + "," + book.getPrice() + ","
+ book.getName() + ";";
}
out = out.substring(0, out.length() - 1);  //去除掉最后一个分号
PrintWriter outs = resp.getWriter();
outs.print(out);
outs.flush();
}
}



安卓客户端部分:

		// 点击获取更新 ,并将获取到的名字,价钱和图片信息通过listview 显示出来。     
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
List<NameValuePair> list = new ArrayList<NameValuePair>();
list.add(new BasicNameValuePair("id", "helloworld"));
// 网络请求
new Thread(new HttpUtil(HttpUtil.httpUrl + "show", list))
.start();
try {
Thread.sleep(8000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String result = HttpUtil.result;
String[] items = { "img", "title", "list_item" };
int[] ids = { R.id.list_item, R.id.list_name, R.id.list_detail };
SimpleAdapter simpleAdapter = new SimpleAdapter(
MainActivity.this, getData(result),
R.layout.activity_list, items, ids);
listview.setAdapter(simpleAdapter);
}
});
}

@SuppressWarnings("deprecation")
List<HashMap<String, Object>> getData(String result) {
String[] results = result.split(";");
List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
for (int i = 0; i < results.length; i++) {
HashMap<String, Object> map = new HashMap<String, Object>();
String[] item = results[i].split(",");
String name = item[2];
String price = item[1];
String pic = item[0];
String tag = "item";
Log.v(tag, item[0]);
// map.put("img", R.drawable.kongnan);
FormatTools format = new FormatTools();
map.put("img", format.Bytes2Drawable(Base64.decode(pic,Base64.DEFAULT)));
map.put("title", name);
map.put("list_item", price);
list.add(map);
}
return list;
}


我反复比对过,这边收到的pic的字符串和那边传输的字符串是一模一样的,没错,而且传输的另外两项信息也没错。问题就出现在把这个字符串进行BASE64解码同时转换成drawable 弹出的错误:
07-29 14:30:37.727: E/BitmapFactory(13946): Unable to decode stream: FileNotFoundException
07-29 14:30:37.727: I/System.out(13946): resolveUri failed on bad bitmap uri: android.graphics.drawable.BitmapDrawable@4208a508




资源找不到,谢谢各位前辈了,实在没辙了。。。




------解决方案--------------------
你  的错误 是不是  stream 没获取到。

我试过 图片 以流 的形式 提交 。
------解决方案--------------------
Unable to decode stream: FileNotFoundException

错误就是  不能 decode  ,文件未找到啊。