代码优化

This commit is contained in:
thinkgem
2020-06-17 15:09:04 +08:00
parent daa19c59ce
commit 47b091e6a1

View File

@@ -456,7 +456,7 @@ class DefaultVFS extends VFS {
// Some versions of JBoss VFS might give a JAR stream even if the resource // Some versions of JBoss VFS might give a JAR stream even if the resource
// referenced by the URL isn't actually a JAR // referenced by the URL isn't actually a JAR
is = url.openStream(); is = url.openStream();
@SuppressWarnings("resource") // @SuppressWarnings("resource")
JarInputStream jarInput = new JarInputStream(is); JarInputStream jarInput = new JarInputStream(is);
log.debug("Listing " + url); log.debug("Listing " + url);
for (JarEntry entry; (entry = jarInput.getNextJarEntry()) != null;) { for (JarEntry entry; (entry = jarInput.getNextJarEntry()) != null;) {
@@ -473,21 +473,22 @@ class DefaultVFS extends VFS {
* then we assume the current resource is not a directory. * then we assume the current resource is not a directory.
*/ */
is = url.openStream(); is = url.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is)); try(BufferedReader reader = new BufferedReader(new InputStreamReader(is))){
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<String>();
for (String line; (line = reader.readLine()) != null;) { for (String line; (line = reader.readLine()) != null;) {
log.debug("Reader entry: " + line); log.debug("Reader entry: " + line);
lines.add(line); lines.add(line);
if (getResources(path + "/" + line).isEmpty()) { if (getResources(path + "/" + line).isEmpty()) {
lines.clear(); lines.clear();
break; break;
}
} }
}
if (!lines.isEmpty()) {
if (!lines.isEmpty()) { log.debug("Listing " + url);
log.debug("Listing " + url); children.addAll(lines);
children.addAll(lines); }
} };
} }
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
/* /*