Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6674: Use try-with-resource in more places and close un-closed resources #33

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -322,7 +322,8 @@ public static void saveToFile(File file, List<String> lines) throws IOException
* on I/O error
*/
public static List<String> loadFromStream(InputStream is) throws IOException {
try (BufferedInputStream bis = new BufferedInputStream(is); BufferedReader r = new BufferedReader(new InputStreamReader(bis))) {
try (BufferedInputStream bis = new BufferedInputStream(is);
BufferedReader r = new BufferedReader(new InputStreamReader(bis))) {
List<String> lines = new ArrayList<>();
while (r.ready()) {
lines.add(r.readLine());
@@ -347,7 +348,8 @@ public static void saveToFile(File file, List<String> lines) throws IOException
* on I/O error
*/
public static void write(InputStream in, File toOutput, boolean append) throws IOException {
try (FileOutputStream fos = new FileOutputStream(toOutput, append); BufferedOutputStream os = new BufferedOutputStream(fos)) {
try (FileOutputStream fos = new FileOutputStream(toOutput, append);
BufferedOutputStream os = new BufferedOutputStream(fos)) {
copy(in, os);
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.