File tree Expand file tree Collapse file tree
HMCLCore/src/main/java/org/jackhuang/hmcl/game Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,13 +88,15 @@ public World(Path file) throws IOException {
8888 root = fs .getPath ("/" );
8989 fileName = FileUtils .getName (this .file );
9090 } else {
91- List <Path > files = Files .list (fs .getPath ("/" )).toList ();
92- if (files .size () != 1 || !Files .isDirectory (files .get (0 ))) {
93- throw new IOException ("Not a valid world zip file" );
94- }
91+ try (Stream <Path > filesStream = Files .list (fs .getPath ("/" ))) {
92+ List <Path > files = filesStream .toList ();
93+ if (files .size () != 1 || !Files .isDirectory (files .get (0 ))) {
94+ throw new IOException ("Not a valid world zip file" );
95+ }
9596
96- root = files .get (0 );
97- fileName = FileUtils .getName (root );
97+ root = files .get (0 );
98+ fileName = FileUtils .getName (root );
99+ }
98100 }
99101
100102 Path levelDat = root .resolve ("level.dat" );
You can’t perform that action at this time.
0 commit comments