Skip to content

Commit

Permalink
Refactor readFromInputStream
Browse files Browse the repository at this point in the history
  • Loading branch information
Grzegorz Piwowarek committed Oct 10, 2016
1 parent 687b7e0 commit 9da1680
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,14 @@ public void givenFilePath_whenUsingFilesLines_thenFileData() throws IOException,
}

private String readFromInputStream(InputStream inputStream) throws IOException {
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
StringBuilder resultStringBuilder = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
resultStringBuilder.append(line);
resultStringBuilder.append("\n");
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
resultStringBuilder.append(line);
resultStringBuilder.append("\n");
}
}
bufferedReader.close();
inputStreamReader.close();
inputStream.close();
return resultStringBuilder.toString();
}
}

0 comments on commit 9da1680

Please sign in to comment.