< prev index next >

src/java.base/windows/classes/jdk/internal/loader/FileURLMapper.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()


  38 
  39 public class FileURLMapper {
  40 
  41     URL url;
  42     String file;
  43 
  44     public FileURLMapper (URL url) {
  45         this.url = url;
  46     }
  47 
  48     /**
  49      * @return the platform specific path corresponding to the URL, and in particular
  50      *  returns a UNC when the authority contains a hostname
  51      */
  52 
  53     public String getPath () {
  54         if (file != null) {
  55             return file;
  56         }
  57         String host = url.getHost();
  58         if (host != null && !host.equals("") &&
  59             !"localhost".equalsIgnoreCase(host)) {
  60             String rest = url.getFile();
  61             String s = host + ParseUtil.decode (url.getFile());
  62             file = "\\\\"+ s.replace('/', '\\');
  63             return file;
  64         }
  65         String path = url.getFile().replace('/', '\\');
  66         file = ParseUtil.decode(path);
  67         return file;
  68     }
  69 
  70     public boolean exists() {
  71         String path = getPath();
  72         File f = new File (path);
  73         return f.exists();
  74     }
  75 }


  38 
  39 public class FileURLMapper {
  40 
  41     URL url;
  42     String file;
  43 
  44     public FileURLMapper (URL url) {
  45         this.url = url;
  46     }
  47 
  48     /**
  49      * @return the platform specific path corresponding to the URL, and in particular
  50      *  returns a UNC when the authority contains a hostname
  51      */
  52 
  53     public String getPath () {
  54         if (file != null) {
  55             return file;
  56         }
  57         String host = url.getHost();
  58         if (host != null && !host.isEmpty() &&
  59             !"localhost".equalsIgnoreCase(host)) {
  60             String rest = url.getFile();
  61             String s = host + ParseUtil.decode (url.getFile());
  62             file = "\\\\"+ s.replace('/', '\\');
  63             return file;
  64         }
  65         String path = url.getFile().replace('/', '\\');
  66         file = ParseUtil.decode(path);
  67         return file;
  68     }
  69 
  70     public boolean exists() {
  71         String path = getPath();
  72         File f = new File (path);
  73         return f.exists();
  74     }
  75 }
< prev index next >