Biblioteca Java - Blame information for rev 3
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
3 | mihai | 1 | /* |
2 | * SourceViewer.java | ||
3 | */ | ||
4 | package lab.scd.net.url_http; | ||
5 | |||
6 | /** | ||
7 | * Class created by @author Mihai HULEA at Feb 25, 2005. | ||
8 | * | ||
9 | * This class is part of the laborator2_net project. | ||
10 | * | ||
11 | */ | ||
12 | import java.net.*; | ||
13 | import java.io.*; | ||
14 | |||
15 | public class SourceViewer { | ||
16 | |||
17 | public static void main (String[] args) { | ||
18 | |||
19 | String url = "http://www.utcluj.ro"; | ||
20 | |||
21 | try { | ||
22 | |||
23 | //Open the URL for reading | ||
24 | URL u = new URL(url); | ||
25 | InputStream in = u.openStream( ); | ||
26 | // buffer the input to increase performance | ||
27 | in = new BufferedInputStream(in); | ||
28 | // chain the InputStream to a Reader | ||
29 | Reader r = new InputStreamReader(in); | ||
30 | int c; | ||
31 | while ((c = r.read( )) != -1) { | ||
32 | System.out.print((char) c); | ||
33 | } | ||
34 | } | ||
35 | catch (MalformedURLException e) { | ||
36 | System.err.println(args[0] + " is not a parseable URL"); | ||
37 | } | ||
38 | catch (IOException e) { | ||
39 | System.err.println(e); | ||
40 | } | ||
41 | |||
42 | } // | ||
43 | } // end SourceViewer |