- 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();
-
-
- }
- }
复制代码 代码和毕老师的一样但是报错/*Type mismatch: cannot convert from java.net.URLConnection to day24.URLConnection*/前面已经导过包了,在$$$$行,URLConnection前面加上java。net。就行了,这是为什么 |
|