读书人

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

发布时间: 2012-01-07 21:41:55 作者: rapoo

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

读书人网 >Java相关

热点推荐