java是网络语言.在网络开发方面自然非常擅长.如果要将url地址读取下来并进行分析,在实际生活中也会有所应用.
import java.net.*; import java.io.*; public class ReadDemo { public static void main(String argv[]) { try { URL url = new URL("http://blog.chinaunix.net/u/15586/showart_1863289.html"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String str; while((str = in.readLine()) != null) System.out.println(str); in.close(); } catch(MalformedURLException e){} catch(IOException e) {} } }
|
阅读(1557) | 评论(0) | 转发(0) |