< prev index next >

src/java.base/share/classes/sun/net/www/protocol/jar/URLJarFile.java

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


  94 
  95     private URLJarFile(File file, URLJarFileCloseController closeController, Runtime.Version version)
  96             throws IOException {
  97         super(file, true, ZipFile.OPEN_READ | ZipFile.OPEN_DELETE, version);
  98         this.closeController = closeController;
  99     }
 100 
 101     private URLJarFile(URL url, URLJarFileCloseController closeController, Runtime.Version version)
 102             throws IOException {
 103         super(new File(ParseUtil.decode(url.getFile())), true, ZipFile.OPEN_READ, version);
 104         this.closeController = closeController;
 105     }
 106 
 107     private static boolean isFileURL(URL url) {
 108         if (url.getProtocol().equalsIgnoreCase("file")) {
 109             /*
 110              * Consider this a 'file' only if it's a LOCAL file, because
 111              * 'file:' URLs can be accessible through ftp.
 112              */
 113             String host = url.getHost();
 114             if (host == null || host.equals("") || host.equals("~") ||
 115                 host.equalsIgnoreCase("localhost"))
 116                 return true;
 117         }
 118         return false;
 119     }
 120 
 121     /**
 122      * Returns the <code>ZipEntry</code> for the given entry name or
 123      * <code>null</code> if not found.
 124      *
 125      * @param name the JAR file entry name
 126      * @return the <code>ZipEntry</code> for the given entry name or
 127      *         <code>null</code> if not found
 128      * @see java.util.zip.ZipEntry
 129      */
 130     public ZipEntry getEntry(String name) {
 131         ZipEntry ze = super.getEntry(name);
 132         if (ze != null) {
 133             if (ze instanceof JarEntry)
 134                 return new URLJarFileEntry((JarEntry)ze);




  94 
  95     private URLJarFile(File file, URLJarFileCloseController closeController, Runtime.Version version)
  96             throws IOException {
  97         super(file, true, ZipFile.OPEN_READ | ZipFile.OPEN_DELETE, version);
  98         this.closeController = closeController;
  99     }
 100 
 101     private URLJarFile(URL url, URLJarFileCloseController closeController, Runtime.Version version)
 102             throws IOException {
 103         super(new File(ParseUtil.decode(url.getFile())), true, ZipFile.OPEN_READ, version);
 104         this.closeController = closeController;
 105     }
 106 
 107     private static boolean isFileURL(URL url) {
 108         if (url.getProtocol().equalsIgnoreCase("file")) {
 109             /*
 110              * Consider this a 'file' only if it's a LOCAL file, because
 111              * 'file:' URLs can be accessible through ftp.
 112              */
 113             String host = url.getHost();
 114             if (host == null || host.isEmpty() || host.equals("~") ||
 115                 host.equalsIgnoreCase("localhost"))
 116                 return true;
 117         }
 118         return false;
 119     }
 120 
 121     /**
 122      * Returns the <code>ZipEntry</code> for the given entry name or
 123      * <code>null</code> if not found.
 124      *
 125      * @param name the JAR file entry name
 126      * @return the <code>ZipEntry</code> for the given entry name or
 127      *         <code>null</code> if not found
 128      * @see java.util.zip.ZipEntry
 129      */
 130     public ZipEntry getEntry(String name) {
 131         ZipEntry ze = super.getEntry(name);
 132         if (ze != null) {
 133             if (ze instanceof JarEntry)
 134                 return new URLJarFileEntry((JarEntry)ze);


< prev index next >