Skip to content

Commit 3a27e48

Browse files
committed
Simplify FileUtils.readAllLines().
1 parent 471181c commit 3a27e48

File tree

1 file changed

+3
-16
lines changed
  • substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/util

1 file changed

+3
-16
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/util/FileUtils.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@
3535
import java.nio.file.Files;
3636
import java.nio.file.Path;
3737
import java.nio.file.Paths;
38-
import java.util.ArrayList;
3938
import java.util.Arrays;
4039
import java.util.List;
4140

42-
import jdk.graal.compiler.debug.DebugContext;
4341
import org.graalvm.nativeimage.ImageSingletons;
4442

4543
import com.oracle.svm.core.SubstrateOptions;
4644
import com.oracle.svm.core.SubstrateUtil;
4745
import com.oracle.svm.core.c.libc.TemporaryBuildDirectoryProvider;
4846

47+
import jdk.graal.compiler.debug.DebugContext;
48+
4949
public class FileUtils {
5050

5151
public static void drainInputStream(InputStream source, OutputStream sink) {
@@ -64,20 +64,7 @@ public static void drainInputStream(InputStream source, OutputStream sink) {
6464
}
6565

6666
public static List<String> readAllLines(InputStream source) {
67-
try {
68-
BufferedReader reader = new BufferedReader(new InputStreamReader(source));
69-
List<String> result = new ArrayList<>();
70-
while (true) {
71-
String line = reader.readLine();
72-
if (line == null) {
73-
break;
74-
}
75-
result.add(line);
76-
}
77-
return result;
78-
} catch (IOException ex) {
79-
throw shouldNotReachHere(ex);
80-
}
67+
return new BufferedReader(new InputStreamReader(source)).lines().toList();
8168
}
8269

8370
public static int executeCommand(String... args) throws IOException, InterruptedException {

0 commit comments

Comments
 (0)