Use FileUtils.copy - #287
Open
sesam wants to merge 1 commit into
Open
Conversation
Untested! This assumes we have `compileSdkVersion 29` or higher. This copy method might be faster, or if noting else, less own code to maintain. I found this since the code scanner warned of potential memory leak (unclosed file descriptors) if copying fails. If using FileUtils won't work, we should add a `finally` block that ensures the Streams get closed and garbage collected.
Member
|
Thanks for the pull request, I'll get back to you about this once I've tested it. |
hsjoberg
reviewed
Mar 10, 2021
Member
There was a problem hiding this comment.
Not sure what FileUtils is referring to, I assume import org.apache.commons.io.FileUtils?
Apache Commons IO is currently not a dependency of the Java project, but could be added.
| } | ||
| in.close(); | ||
| out.close(); | ||
| FileUtils.copy(new FileInputStream(source), new FileOutputStream(destination)); |
Member
There was a problem hiding this comment.
- FileUtils.copy(new FileInputStream(source), new FileOutputStream(destination));
+ FileUtils.copy(new FileInputStream(sourceLocation), new FileOutputStream(targetLocation));
hsjoberg
force-pushed
the
master
branch
3 times, most recently
from
August 20, 2021 12:52
2843ed1 to
5b9f752
Compare
hsjoberg
force-pushed
the
master
branch
4 times, most recently
from
November 4, 2021 03:06
ce95362 to
183c24b
Compare
hsjoberg
force-pushed
the
master
branch
16 times, most recently
from
December 31, 2021 16:27
eea19ec to
edb9b80
Compare
hsjoberg
force-pushed
the
master
branch
5 times, most recently
from
December 31, 2021 16:28
35daec7 to
51ec3e4
Compare
hsjoberg
force-pushed
the
master
branch
9 times, most recently
from
March 28, 2022 15:41
ecc4b42 to
91833d0
Compare
hsjoberg
force-pushed
the
master
branch
2 times, most recently
from
May 8, 2022 08:50
07e4213 to
9961675
Compare
hsjoberg
force-pushed
the
master
branch
2 times, most recently
from
May 29, 2023 23:13
0600257 to
25d96d6
Compare
hsjoberg
force-pushed
the
master
branch
3 times, most recently
from
February 18, 2026 14:47
aa1af8c to
121153d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Untested!
This assumes we have
compileSdkVersion 29or higher. This copy method might be faster, or if noting else, less own code to maintain.I found this since the code scanner warned of potential memory leak (unclosed file descriptors) if copying fails. If using FileUtils won't work, we should add a
finallyblock that ensures the Streams get closed and garbage collected.