package primer3; // primer iz knjige, argument komandne linije: // http://www.oreilly.com import java.io.*; import java.net.*; public class SourceViewer { public static void main(String[] args) { /* System.getProperties().put("proxyHost", "proxy.rcub.bg.ac.rs"); System.getProperties().put("proxyPort", "8080"); */ if(args.length > 0){ try{ // Open the URL for reading URL u = new URL(args[0]); InputStream in = u.openStream(); //buffer the input to increase performance in = new BufferedInputStream(in); //chain the InputStream to a Reader Reader r = new InputStreamReader(in); int c; while((c=r.read())!=-1) System.out.print((char)c); }catch(MalformedURLException ex){ System.err.println(args[0] + " is not a parseable URL"); }catch(IOException ex){ System.err.println(ex); } } } }