1 / 15
文档名称:

JAVA通过url获取网页内容.doc

格式:doc   页数:15页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

JAVA通过url获取网页内容.doc

上传人:875845154 2016/6/26 文件大小:0 KB

下载得到文件列表

JAVA通过url获取网页内容.doc

相关文档

文档介绍

文档介绍:import .*; import .URL; import .URLConnection; public class TestURL { public static void main(String[] args) throws IOException { test4(); test3(); test2(); test(); } /** * 获取 URL 指定的资源。** ***@throws IOException */ public static void test4() throws IOException { URL url = new URL( "./attachment/200811/"); // 获得此 URL 的内容。 Object obj = (); (().getName()); } /** * 获取 URL 指定的资源** ***@throws IOException */ public static void test3() throws IOException { URL url = new URL("http: //n/soft/"); // 返回一个 URLConnection 对象,它表示到 URL 所引用的远程对象的连接。 URLConnection uc= (); // 打开的连接读取的输入流。 InputStream in= (); int c; while ((c = ()) != -1) (c); (); } /** * 读取 URL 指定的网页内容** ***@throws IOException */ public static void test2() throws IOException { URL url = new URL("http: //n/soft/"); // 打开到此 URL 的连接并返回一个用于从该连接读入的 InputStream 。 Reader reader = new InputStreamReader( new BufferedInputStream(())); int c; while ((c = ()) != -1) { (( char ) c); } (); } /** * 获取 URL 的输入流,并输出** ***@throws IOException */ public static void test() throws IOException { URL url = new URL("./62575/120430"); // 打开到此 URL 的连接并返回一个用于从该连接读入的 InputStream 。 InputStream in= (); int c; while ((c = ()) != -1) (c); (); }}