1
0

[HUDI-1913] Using streams instead of loops for input/output (#2962)

This commit is contained in:
zhangminglei
2021-05-19 09:13:38 +08:00
committed by GitHub
parent 5d1f592395
commit fe3f5c2d56
4 changed files with 12 additions and 25 deletions

View File

@@ -212,14 +212,11 @@ public class UtilitiesTestBase {
// to get hold of resources bundled with jar
private static ClassLoader classLoader = Helpers.class.getClassLoader();
public static String readFile(String testResourcePath) throws IOException {
public static String readFile(String testResourcePath) {
BufferedReader reader =
new BufferedReader(new InputStreamReader(classLoader.getResourceAsStream(testResourcePath)));
StringBuffer sb = new StringBuffer();
String line;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
reader.lines().forEach(line -> sb.append(line).append("\n"));
return sb.toString();
}
@@ -227,10 +224,7 @@ public class UtilitiesTestBase {
BufferedReader reader =
new BufferedReader(new InputStreamReader(new FileInputStream(absolutePathForResource)));
StringBuffer sb = new StringBuffer();
String line;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
reader.lines().forEach(line -> sb.append(line).append("\n"));
return sb.toString();
}