[HUDI-1913] Using streams instead of loops for input/output (#2962)
This commit is contained in:
@@ -112,10 +112,7 @@ public class HoodieWithTimelineServer implements Serializable {
|
||||
|
||||
try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
String line;
|
||||
while ((line = rd.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
rd.lines().forEach(result::append);
|
||||
System.out.println("Got result (" + result + ")");
|
||||
return result.toString();
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user