The method openConnection() is undefined for the type URI
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLConnection;
public class UrlImage {
public static void main(String[] args) {
String str="http://www.icon.nipic.com/BannerPic/20161008/home/20161008145324.jpg";
try {
URI url=new URI("http://icon.nipic.com/BannerPic/20161008/home/20161008145324.jpg");
URLConnection connection=url.openConnection();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
报错如下:The method openConnection() is undefined for the type URI
谢谢了。我查看了api 与别人写的文档,都可以啊