首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java相关 >

android与c#通过socket传输图片,该怎么处理

2012-01-07 
android与c#通过socket传输图片java的部分代码:public Bitmap sendMsg(String msg){try{PrintWriter out

android与c#通过socket传输图片
java的部分代码:
public Bitmap sendMsg(String msg)
{
try
{
PrintWriter out = new PrintWriter(socket1.getOutputStream());
out.println(msg);
out.flush();
InputStream ips = socket1.getInputStream();
return BitmapFactory.decodeStream(ips);
}
catch(IOException e)
{
e.printStackTrace();
}
return null;
}

执行完return BitmapFactory.decodeStream(ips);后会跳到return null;返回null,为什么?
没有发生和捕捉到异常。

[解决办法]
你把catch(IOException e)

的IOException 改为Exception 试试,可能不是IOException 异常

热点排行