< prev index next >

src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad


  66          */
  67         super.parseURL(u, spec.replace(File.separatorChar, '/'), start, limit);
  68     }
  69 
  70     public synchronized URLConnection openConnection(URL url)
  71         throws IOException {
  72         return openConnection(url, null);
  73     }
  74 
  75     public synchronized URLConnection openConnection(URL url, Proxy p)
  76            throws IOException {
  77 
  78         String path;
  79         String file = url.getFile();
  80         String host = url.getHost();
  81 
  82         path = ParseUtil.decode(file);
  83         path = path.replace('/', '\\');
  84         path = path.replace('|', ':');
  85 
  86         if ((host == null) || host.equals("") ||
  87                 host.equalsIgnoreCase("localhost") ||
  88                 host.equals("~")) {
  89            return createFileURLConnection(url, new File(path));
  90         }
  91 
  92         /*
  93          * attempt to treat this as a UNC path. See 4180841
  94          */
  95         path = "\\\\" + host + path;
  96         File f = new File(path);
  97         if (f.exists()) {
  98             return createFileURLConnection(url, f);
  99         }
 100 
 101         /*
 102          * Now attempt an ftp connection.
 103          */
 104         URLConnection uc;
 105         URL newurl;
 106 




  66          */
  67         super.parseURL(u, spec.replace(File.separatorChar, '/'), start, limit);
  68     }
  69 
  70     public synchronized URLConnection openConnection(URL url)
  71         throws IOException {
  72         return openConnection(url, null);
  73     }
  74 
  75     public synchronized URLConnection openConnection(URL url, Proxy p)
  76            throws IOException {
  77 
  78         String path;
  79         String file = url.getFile();
  80         String host = url.getHost();
  81 
  82         path = ParseUtil.decode(file);
  83         path = path.replace('/', '\\');
  84         path = path.replace('|', ':');
  85 
  86         if ((host == null) || host.isEmpty() ||
  87                 host.equalsIgnoreCase("localhost") ||
  88                 host.equals("~")) {
  89            return createFileURLConnection(url, new File(path));
  90         }
  91 
  92         /*
  93          * attempt to treat this as a UNC path. See 4180841
  94          */
  95         path = "\\\\" + host + path;
  96         File f = new File(path);
  97         if (f.exists()) {
  98             return createFileURLConnection(url, f);
  99         }
 100 
 101         /*
 102          * Now attempt an ftp connection.
 103          */
 104         URLConnection uc;
 105         URL newurl;
 106 


< prev index next >