- package day24;
- /*
- * 演示urlconnect类
- */
- import java.net.*;
- import java.io.*;
- public class URLConnection {
- public static void main(String[] args)throws Exception
- {
- URL url=new URL("http://127.0.0.1:10008/myweb/demo.html");
-
- //URLConnection conn=url.openConnection();
-
- java.net.URLConnection conn=url.openConnection();//¥¥¥¥
-
- System.out.println(conn);
-
- InputStream in=conn.getInputStream();
- }
- }
- /*
- * 代码和毕老师的一样,开始也导包了,为什么还要在¥¥¥处加上java.net.才正确呢?错误提示如下
- * Type mismatch: cannot convert from java.net.URLConnection to day24.URLConnection
- */
复制代码 |
|