Skip to content

Commit

Permalink
refactor: try-with-resources 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
yonghwankim-dev committed Oct 18, 2024
1 parent eecf2b8 commit 58c369c
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
chain.doFilter(request, response);
}

private static void readPart(Part part) throws IOException {
InputStream inputStream = part.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
private static void readPart(Part part) {
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
try (InputStream inputStream = part.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
log.error(e.getMessage(), e);
}
log.info("{} : {}", part.getName(), sb);
log.info("name={} : {}", part.getName(), sb);
}
}

0 comments on commit 58c369c

Please sign in to comment.