List of usage examples for java.net URL getProtocol
public String getProtocol()
From source file:Main.java
public static void main(String[] argv) throws Exception { URL url = new URL("http://hostname:80/index.html#_top_"); String protocol = url.getProtocol(); // http String host = url.getHost(); // hostname int port = url.getPort(); // 80 String file = url.getFile(); // index.html String ref = url.getRef(); // _top_ }
From source file:MainClass.java
public static void main(String args[]) throws Exception { URL hp = new URL("http://www.java2s.com"); System.out.println("Protocol: " + hp.getProtocol()); System.out.println("Port: " + hp.getPort()); System.out.println("Host: " + hp.getHost()); System.out.println("File: " + hp.getFile()); System.out.println("Ext:" + hp.toExternalForm()); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { URL url = new URL("http://www.yahoo.com:80/en/index.html?name=joe#first"); System.out.println("protocol:" + url.getProtocol()); System.out.println("prot:" + url.getPort()); System.out.println("host:" + url.getHost()); System.out.println("path:" + url.getPath()); System.out.println("file:" + url.getFile()); System.out.println("query:" + url.getQuery()); System.out.println("ref:" + url.getRef()); }
From source file:Main.java
public static void main(String[] args) throws Exception { URL url = new URL(args[0]); System.out.println("URL is " + url.toString()); System.out.println("protocol is " + url.getProtocol()); System.out.println("authority is " + url.getAuthority()); System.out.println("file name is " + url.getFile()); System.out.println("host is " + url.getHost()); System.out.println("path is " + url.getPath()); System.out.println("port is " + url.getPort()); System.out.println("default port is " + url.getDefaultPort()); System.out.println("query is " + url.getQuery()); System.out.println("ref is " + url.getRef()); }
From source file:Main.java
public static void main(String args[]) throws Exception { URL u = new URL("http://www.yourserver.com/abc/demo.htm"); System.out.println("The URL is " + u); System.out.println("The protocol part is " + u.getProtocol()); }
From source file:org.apache.infra.reviewboard.ReviewBoard.java
public static void main(String... args) throws IOException { URL url = new URL(REVIEW_BOARD_URL); HttpHost host = new HttpHost(url.getHost(), url.getPort(), url.getProtocol()); Executor executor = Executor.newInstance().auth(host, REVIEW_BOARD_USERNAME, REVIEW_BOARD_PASSWORD) .authPreemptive(host);/*ww w. j a v a 2 s .c o m*/ Request request = Request.Get(REVIEW_BOARD_URL + "/api/review-requests/"); Response response = executor.execute(request); request = Request.Get(REVIEW_BOARD_URL + "/api/review-requests/"); response = executor.execute(request); ObjectMapper mapper = new ObjectMapper(); JsonNode json = mapper.readTree(response.returnResponse().getEntity().getContent()); JsonFactory factory = new JsonFactory(); JsonGenerator generator = factory.createGenerator(new PrintWriter(System.out)); generator.setPrettyPrinter(new DefaultPrettyPrinter()); mapper.writeTree(generator, json); }
From source file:GetURLParts.java
public static void main(String args[]) { try {/*from ww w. j a va 2s . com*/ URL u = new URL("http://www.java2s.com"); System.out.println("The URL is " + u); System.out.println("The protocol part is " + u.getProtocol()); System.out.println("The host part is " + u.getHost()); System.out.println("The port part is " + u.getPort()); System.out.println("The file part is " + u.getFile()); System.out.println("The ref part is " + u.getRef()); } // end try catch (MalformedURLException e) { System.err.println("not a URL I understand."); } }
From source file:ParseURL.java
public static void main(String[] args) throws Exception { URL aURL = new URL("http://java.sun.com:80/docs/books/" + "tutorial/index.html#DOWNLOADING"); System.out.println("protocol = " + aURL.getProtocol()); System.out.println("host = " + aURL.getHost()); System.out.println("filename = " + aURL.getFile()); System.out.println("port = " + aURL.getPort()); System.out.println("ref = " + aURL.getRef()); }
From source file:de.jwi.ftp.FTPUploader.java
public static void main(String[] args) throws Exception { URL url = new URL("ftp://ftp:none@localhost/tmp"); String protocol = url.getProtocol(); String host = url.getHost();//from w w w . jav a2 s .c o m String userInfo = url.getUserInfo(); String path = url.getPath(); String file = url.getFile(); File f = new File("D:/temp/out"); List l = new ArrayList(); l.add(f); String s = upload(url, l); System.out.println(s); int x = 5; }
From source file:MinAppletviewer.java
public static void main(String args[]) throws Exception { AppSupport theAppSupport = new AppSupport(); JFrame f = new JFrame(); URL toload = new URL(args[0]); String host = toload.getHost(); int port = toload.getPort(); String protocol = toload.getProtocol(); String path = toload.getFile(); int join = path.lastIndexOf('/'); String file = path.substring(join + 1); path = path.substring(0, join + 1);/* ww w . j a v a 2 s . com*/ theAppSupport.setCodeBase(new URL(protocol, host, port, path)); theAppSupport.setDocumentBase(theAppSupport.getCodeBase()); URL[] bases = { theAppSupport.getCodeBase() }; URLClassLoader loader = new URLClassLoader(bases); Class theAppletClass = loader.loadClass(file); Applet theApplet = (Applet) (theAppletClass.newInstance()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(theApplet, BorderLayout.CENTER); theApplet.setStub(theAppSupport); f.setSize(200, 200); f.setVisible(true); theApplet.init(); theApplet.start(); }