theURL = s;
protocol = protocol.toLowerCase(); try { Class ph = Class.forName(protocol + "URLStreamHandler"); Object o = ph.newInstance(); return (URLStreamHandler) o; } catch (Exception e) { return null; }
if (args.length == 1) { ProtocolTester pt = new ProtocolTester(args[0]); URL.setURLStreamHandlerFactory(pt); pt.test(); } else { System.err.println("Usage: java ProtocolTester url"); }
String theLine; try { URL u = new URL(theURL); DataInputStream dis = new DataInputStream(u.openStream()); while ((theLine = dis.readLine()) != null) { System.out.println(theLine); } } catch (IOException e) { System.err.println(e); }