< prev index next >

src/java.base/share/classes/jdk/internal/module/ModulePatcher.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


 535                 @Override
 536                 public ByteBuffer getByteBuffer() throws IOException {
 537                     return ByteBuffer.wrap(Files.readAllBytes(file));
 538                 }
 539                 @Override
 540                 public InputStream getInputStream() throws IOException {
 541                     return Files.newInputStream(file);
 542                 }
 543                 @Override
 544                 public int getContentLength() throws IOException {
 545                     long size = Files.size(file);
 546                     return (size > Integer.MAX_VALUE) ? -1 : (int)size;
 547                 }
 548             };
 549         }
 550 
 551         @Override
 552         public Stream<String> list() throws IOException {
 553             return Files.walk(dir, Integer.MAX_VALUE)
 554                         .map(f -> Resources.toResourceName(dir, f))
 555                         .filter(s -> s.length() > 0);
 556         }
 557     }
 558 
 559 
 560     /**
 561      * Derives a package name from the file path of an entry in an exploded patch
 562      */
 563     private static String toPackageName(Path top, Path file) {
 564         Path entry = top.relativize(file);
 565         Path parent = entry.getParent();
 566         if (parent == null) {
 567             return warnIfModuleInfo(top, entry.toString());
 568         } else {
 569             return parent.toString().replace(File.separatorChar, '.');
 570         }
 571     }
 572 
 573     /**
 574      * Returns true if the given file exists and is a hidden file
 575      */




 535                 @Override
 536                 public ByteBuffer getByteBuffer() throws IOException {
 537                     return ByteBuffer.wrap(Files.readAllBytes(file));
 538                 }
 539                 @Override
 540                 public InputStream getInputStream() throws IOException {
 541                     return Files.newInputStream(file);
 542                 }
 543                 @Override
 544                 public int getContentLength() throws IOException {
 545                     long size = Files.size(file);
 546                     return (size > Integer.MAX_VALUE) ? -1 : (int)size;
 547                 }
 548             };
 549         }
 550 
 551         @Override
 552         public Stream<String> list() throws IOException {
 553             return Files.walk(dir, Integer.MAX_VALUE)
 554                         .map(f -> Resources.toResourceName(dir, f))
 555                         .filter(s -> !s.isEmpty());
 556         }
 557     }
 558 
 559 
 560     /**
 561      * Derives a package name from the file path of an entry in an exploded patch
 562      */
 563     private static String toPackageName(Path top, Path file) {
 564         Path entry = top.relativize(file);
 565         Path parent = entry.getParent();
 566         if (parent == null) {
 567             return warnIfModuleInfo(top, entry.toString());
 568         } else {
 569             return parent.toString().replace(File.separatorChar, '.');
 570         }
 571     }
 572 
 573     /**
 574      * Returns true if the given file exists and is a hidden file
 575      */


< prev index next >