< prev index next >

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

Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb


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




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


< prev index next >