home *** CD-ROM | disk | FTP | other *** search
- package sun.net.www.protocol.file;
-
- import java.io.File;
- import java.io.IOException;
- import java.net.URL;
- import java.net.URLConnection;
- import java.net.URLStreamHandler;
-
- public class Handler extends URLStreamHandler {
- private String getHost(URL var1) {
- String var2 = var1.getHost();
- if (var2 == null) {
- var2 = "";
- }
-
- return var2;
- }
-
- protected void parseURL(URL var1, String var2, int var3, int var4) {
- super.parseURL(var1, var2.replace(File.separatorChar, '/'), var3, var4);
- }
-
- public synchronized URLConnection openConnection(URL var1) throws IOException {
- String var2 = var1.getHost();
- if (var2 != null && !var2.equals("") && !var2.equals("~") && !var2.equals("localhost")) {
- try {
- URL var8 = new URL("file", "", "//" + var2 + var1.getPath());
- FileURLConnection var9 = new FileURLConnection(var8);
- var9.connect();
- return var9;
- } catch (IOException var7) {
- URLConnection var3;
- try {
- URL var4 = new URL("ftp", var2, var1.getFile() + (var1.getRef() == null ? "" : "#" + var1.getRef()));
- var3 = var4.openConnection();
- } catch (IOException var6) {
- var3 = null;
- }
-
- if (var3 == null) {
- throw new IOException("Unable to connect to: " + var1.toExternalForm());
- } else {
- return var3;
- }
- }
- } else {
- return new FileURLConnection(var1);
- }
- }
- }
-