getInputStream() 方法异常:java.io.FileNotFoundException


getInputStream() 方法异常:java.io.FileNotFoundException

解决方法:想判断返回值,在获取相应流

1
2
3
4
5
6
7
InputStream is = null;
int code = conn.getResponseCode();
if (code == 200) {
is = conn.getInputStream();
} else {
is = conn.getErrorStream();
}