Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
URL.openStream()无响应_Url_Stream_Inputstream - Fatal编程技术网

URL.openStream()无响应

URL.openStream()无响应,url,stream,inputstream,Url,Stream,Inputstream,我现在测试了一个。在ip摄像机上拍照是很容易的 public static void main(String[] args) throws Exception { URL url = new URL("http://192.168.1.210:5500/snapshot.cgi?user=admin&pwd=123456"); InputStream is = url.openStream(); BufferedImage image = null; i

我现在测试了一个。在ip摄像机上拍照是很容易的

public static void main(String[] args) throws Exception {

    URL url = new URL("http://192.168.1.210:5500/snapshot.cgi?user=admin&pwd=123456");
    InputStream is = url.openStream();
    BufferedImage image = null;
    image = ImageIO.read(is);
    is.close();

}
我的问题是这行:“InputStream is=url.openStream();”我知道我的地址是错误的,但它仍然是块,我没有错误或其他东西。有人有办法解决我的问题吗?提前感谢。

的Java API文档

打开与此URL的连接并返回InputStream以从该连接读取。此方法是以下内容的简写:

openConnection().getInputStream()

因此,您可以尝试首先通过
openConnection()
打开一个连接,然后在该对象上设置超时,然后调用
getInputStream()
,这可能会起作用

    URLConnection urlcon = url.openConnection();
    urlcon.setReadTimeout(10000);
    InputStream is = urlcon.getInputStream();

或者至少给你一点关于问题可能是什么的更多信息。

是的,我知道,但我不知道如何将inputStream()更改为BufferedImage我不明白你的意思。你不能像上面的例子那样继续吗
BufferedImage image=ImageIO.read(is)
No,因为我不知道摄像头的地址是否正常not@blackcat18:问题是什么?