日期:2014-05-20  浏览次数:21110 次

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 异常