Skip to content

Commit b070476

Browse files
committed
Fix NcepLocalTables path finder
1 parent 998c925 commit b070476

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

grib/src/main/java/ucar/nc2/grib/grib2/table/NcepLocalTables.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,21 @@ private String[] getResourceListing(String path) throws URISyntaxException, IOEx
6969
/* A JAR path */
7070
String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf("!")); // strip out only the JAR file
7171
Enumeration<JarEntry> entries;
72+
Set<String> result = new HashSet<>(); // avoid duplicates in case it is a subdirectory
7273
try (JarFile jar = new JarFile(URLDecoder.decode(jarPath, CDM.UTF8))) {
7374
// gives ALL entries in jar
7475
entries = jar.entries();
75-
}
76-
Set<String> result = new HashSet<>(); // avoid duplicates in case it is a subdirectory
77-
while (entries.hasMoreElements()) {
78-
String name = entries.nextElement().getName();
79-
if (name.startsWith(path)) { // filter according to the path
80-
String entry = name.substring(path.length());
81-
int checkSubdir = entry.indexOf("/");
82-
if (checkSubdir >= 0) {
83-
// if it is a subdirectory, we just return the directory name
84-
entry = entry.substring(0, checkSubdir);
76+
while (entries.hasMoreElements()) {
77+
String name = entries.nextElement().getName();
78+
if (name.startsWith(path)) { // filter according to the path
79+
String entry = name.substring(path.length());
80+
int checkSubdir = entry.indexOf("/");
81+
if (checkSubdir >= 0) {
82+
// if it is a subdirectory, we just return the directory name
83+
entry = entry.substring(0, checkSubdir);
84+
}
85+
result.add(entry);
8586
}
86-
result.add(entry);
8787
}
8888
}
8989
return result.toArray(new String[0]);

0 commit comments

Comments
 (0)