Java by API/java.net/URI — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 14:16, 31 мая 2010
Содержание
URI: getAuthority()
import java.net.URI;
import java.net.URISyntaxException;
public class Main {
public static void main(String[] args) throws NullPointerException, URISyntaxException {
URI uri = new URI("http://www.example.org");
System.out.println("URI : " + uri);
System.out.println("Raw Authority : " + uri.getRawAuthority());
System.out.println("Raw Fragment : " + uri.getRawFragment());
System.out.println("Fragment : " + uri.getFragment());
System.out.println("Authority : " + uri.getAuthority());
System.out.println("Authority : " + uri.getRawPath());
System.out.println("RawQuery : " + uri.getRawQuery());
System.out.println("RawSchemeSpecificPart : " + uri.getRawSchemeSpecificPart());
System.out.println("RawUserInfo : " + uri.getRawUserInfo());
}
}
URI: getFragment()
import java.net.URI;
import java.net.URISyntaxException;
public class Main {
public static void main(String[] args) throws NullPointerException, URISyntaxException {
URI uri = new URI("http://www.example.org");
System.out.println("URI : " + uri);
System.out.println("Raw Authority : " + uri.getRawAuthority());
System.out.println("Raw Fragment : " + uri.getRawFragment());
System.out.println("Fragment : " + uri.getFragment());
System.out.println("Authority : " + uri.getAuthority());
System.out.println("Authority : " + uri.getRawPath());
System.out.println("RawQuery : " + uri.getRawQuery());
System.out.println("RawSchemeSpecificPart : " + uri.getRawSchemeSpecificPart());
System.out.println("RawUserInfo : " + uri.getRawUserInfo());
}
}
URI: getRawAuthority()
import java.net.URI;
import java.net.URISyntaxException;
public class Main {
public static void main(String[] args) throws NullPointerException, URISyntaxException {
URI uri = new URI("http://www.example.org");
System.out.println("URI : " + uri);
System.out.println("Raw Authority : " + uri.getRawAuthority());
System.out.println("Raw Fragment : " + uri.getRawFragment());
System.out.println("Fragment : " + uri.getFragment());
System.out.println("Authority : " + uri.getAuthority());
System.out.println("Authority : " + uri.getRawPath());
System.out.println("RawQuery : " + uri.getRawQuery());
System.out.println("RawSchemeSpecificPart : " + uri.getRawSchemeSpecificPart());
System.out.println("RawUserInfo : " + uri.getRawUserInfo());
}
}
URI: getRawFragment()
import java.net.URI;
import java.net.URISyntaxException;
public class Main {
public static void main(String[] args) throws NullPointerException, URISyntaxException {
URI uri = new URI("http://www.example.org");
System.out.println("URI : " + uri);
System.out.println("Raw Authority : " + uri.getRawAuthority());
System.out.println("Raw Fragment : " + uri.getRawFragment());
System.out.println("Fragment : " + uri.getFragment());
System.out.println("Authority : " + uri.getAuthority());
System.out.println("Authority : " + uri.getRawPath());
System.out.println("RawQuery : " + uri.getRawQuery());
System.out.println("RawSchemeSpecificPart : " + uri.getRawSchemeSpecificPart());
System.out.println("RawUserInfo : " + uri.getRawUserInfo());
}
}
URI: getRawPath()
import java.net.URI;
import java.net.URISyntaxException;
public class Main {
public static void main(String[] args) throws NullPointerException, URISyntaxException {
URI uri = new URI("http://www.example.org");
System.out.println("URI : " + uri);
System.out.println("Raw Authority : " + uri.getRawAuthority());
System.out.println("Raw Fragment : " + uri.getRawFragment());
System.out.println("Fragment : " + uri.getFragment());
System.out.println("Authority : " + uri.getAuthority());
System.out.println("Authority : " + uri.getRawPath());
System.out.println("RawQuery : " + uri.getRawQuery());
System.out.println("RawSchemeSpecificPart : " + uri.getRawSchemeSpecificPart());
System.out.println("RawUserInfo : " + uri.getRawUserInfo());
}
}
URI: getRawQuery()
import java.net.URI;
import java.net.URISyntaxException;
public class Main {
public static void main(String[] args) throws NullPointerException, URISyntaxException {
URI uri = new URI("http://www.example.org");
System.out.println("URI : " + uri);
System.out.println("Raw Authority : " + uri.getRawAuthority());
System.out.println("Raw Fragment : " + uri.getRawFragment());
System.out.println("Fragment : " + uri.getFragment());
System.out.println("Authority : " + uri.getAuthority());
System.out.println("Authority : " + uri.getRawPath());
System.out.println("RawQuery : " + uri.getRawQuery());
System.out.println("RawSchemeSpecificPart : " + uri.getRawSchemeSpecificPart());
System.out.println("RawUserInfo : " + uri.getRawUserInfo());
}
}
URI: getRawSchemeSpecificPart()
import java.net.URI;
import java.net.URISyntaxException;
public class Main {
public static void main(String[] args) throws NullPointerException, URISyntaxException {
URI uri = new URI("http://www.example.org");
System.out.println("URI : " + uri);
System.out.println("Raw Authority : " + uri.getRawAuthority());
System.out.println("Raw Fragment : " + uri.getRawFragment());
System.out.println("Fragment : " + uri.getFragment());
System.out.println("Authority : " + uri.getAuthority());
System.out.println("Authority : " + uri.getRawPath());
System.out.println("RawQuery : " + uri.getRawQuery());
System.out.println("RawSchemeSpecificPart : " + uri.getRawSchemeSpecificPart());
System.out.println("RawUserInfo : " + uri.getRawUserInfo());
}
}
URI: getRawUserInfo()
import java.net.URI;
import java.net.URISyntaxException;
public class Main {
public static void main(String[] args) throws NullPointerException, URISyntaxException {
URI uri = new URI("http://www.example.org");
System.out.println("URI : " + uri);
System.out.println("Raw Authority : " + uri.getRawAuthority());
System.out.println("Raw Fragment : " + uri.getRawFragment());
System.out.println("Fragment : " + uri.getFragment());
System.out.println("Authority : " + uri.getAuthority());
System.out.println("Authority : " + uri.getRawPath());
System.out.println("RawQuery : " + uri.getRawQuery());
System.out.println("RawSchemeSpecificPart : " + uri.getRawSchemeSpecificPart());
System.out.println("RawUserInfo : " + uri.getRawUserInfo());
}
}
URI: toURL()
import java.io.File;
import java.io.InputStream;
import java.net.URI;
public class Main {
public static void main(String[] argv) throws Exception {
File file = new File("filename");
URI uri = file.toURI();
file = new File(uri.toURL().getFile());
InputStream is = uri.toURL().openStream();
is.close();
}
}