Java url Network Communication (2) -- protocol types supported by JAVA test URLs
If you do not know the protocol types supported by the current virtual machine, you can refer to this article.
The test experiment in this paper is from: http://www.java2s.com/Tutorial/Java/0320__Network/ProtocolTester.htm
- Public class TestURLProtocol {
- Public static void main (String [] args ){
- String host = "www.baidu.com ";
- String file = "/index.html ";
- String [] schames = {"http", "https", "ftp", "mailto", "telnet", "file", "ldap", "gopher ",
- "Jdbc", "rmi", "jndi", "jar", "doc", "netdoc", "nfs", "verbatim", "finger", "daytime ", ""
- + "Systemresource "};
- For (int I = 0; I <schames. length; I ++ ){
- Try {
- URL url = new URL (schames [I], host, file );
- System. out. println (schames [I] + "is supported \ r \ n ");
- } Catch (MalformedURLException e ){
- // TODO Auto-generated catch block
- E. printStackTrace ();
- System. out. println (schames [I] + "is not supported \ r \ n ");
- }
- }
- }
The test results are as follows:
- Http is supported
- Https is supported
- Ftp is supported
- Mailto is supported
- Java.net. MalformedURLException: unknown protocol: telnet
- At java.net. URL. <init> (URL. java: 413)
- At java.net. URL. <init> (URL. java: 302)
- At java.net. URL. <init> (URL. java: 325)
- At urlSample. TestURLProtocol. main (TestURLProtocol. java: 17)
- Telnet is not supported
- File is supported
- Java.net. MalformedURLException: unknown protocol: ldap
- At java.net. URL. <init> (URL. java: 413)
- At java.net. URL. <init> (URL. java: 302)
- At java.net. URL. <init> (URL. java: 325) ldap is not supported
- Gopher is not supported
- Jdbc is not supported
- Rmi is not supported
- Jndi is not supported
- Jar is supported
- At urlSample. TestURLProtocol. main (TestURLProtocol. java: 17)
- Java.net. MalformedURLException: unknown protocol: gopher
- At java.net. URL. <init> (URL. java: 413)
- At java.net. URL. <init> (URL. java: 302)
- At java.net. URL. <init> (URL. java: 325)
- At urlSample. TestURLProtocol. main (TestURLProtocol. java: 17)
- Java.net. MalformedURLException: unknown protocol: jdbc
- At java.net. URL. <init> (URL. java: 413)
- At java.net. URL. <init> (URL. java: 302)
- At java.net. URL. <init> (URL. java: 325)
- At urlSample. TestURLProtocol. main (TestURLProtocol. java: 17)
- Java.net. MalformedURLException: unknown protocol: rmi
- At java.net. URL. <init> (URL. java: 413)
- At java.net. URL. <init> (URL. java: 302)
- At java.net. URL. <init> (URL. java: 325)
- At urlSample. TestURLProtocol. main (TestURLProtocol. java: 17)
- Java.net. MalformedURLException: unknown protocol: jndi
- At java.net. URL. <init> (URL. java: 413)
- At java.net. URL. <init> (URL. java: 302)
- At java.net. URL. <init> (URL. java: 325)
- At urlSample. TestURLProtocol. main (TestURLProtocol. java: 17)
- Java.net. MalformedURLException: unknown protocol: doc
- At java.net. URL. <init> (URL. java: 413)
- At java.net. URL. <init> (URL. java: 302)
- At java.net. URL. <init> (URL. java: 325)
- At urlSample. TestURLProtocol. main (TestURLProtocol. java: 17)
- Doc is not supported
- Netdoc is supported
- Java.net. MalformedURLException: unknown protocol: nfs
- At java.net. URL. <init> (URL. java: 413)
- At java.net. URL. <init> (URL. java: 302)
- At java.net. URL. <init> (URL. java: 325)
- At urlSample. TestURLProtocol. main (TestURLProtocol. java: 17)
- Nfs is not supported
- Java.net. MalformedURLException: unknown protocol: verbatim
- At java.net. URL. <init> (URL. java: 413)
- At java.net. URL. <init> (URL. java: 302)
- At java.net. URL. <init> (URL. java: 325)
- At urlSample. TestURLProtocol. main (TestURLProtocol. java: 17)
- Verbatim is not supported
- Java.net. MalformedURLException: unknown protocol: finger
- At java.net. URL. <init> (URL. java: 413)
- At java.net. URL. <init> (URL. java: 302)
- At java.net. URL. <init> (URL. java: 325)
- At urlSample. TestURLProtocol. main (TestURLProtocol. java: 17)
- Finger is not supported
- Java.net. MalformedURLException: unknown protocol: daytime
- At java.net. URL. <init> (URL. java: 413)
- At java.net. URL. <init> (URL. java: 302)
- At java.net. URL. <init> (URL. java: 325)
- At urlSample. TestURLProtocol. main (TestURLProtocol. java: 17)
- Daytime is not supported
- Java.net. MalformedURLException: unknown protocol: systemresource
- At java.net. URL. <init> (URL. java: 413)
- At java.net. URL. <init> (URL. java: 302)
- At java.net. URL. <init> (URL. java: 325)
- At urlSample. TestURLProtocol. main (TestURLProtocol. java: 17)
- Systemresource is not supported