-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Use FileUtils.copy #287
base: master
Are you sure you want to change the base?
Use FileUtils.copy #287
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.
Thanks for the pull request, I'll get back to you about this once I've tested it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- FileUtils.copy(new FileInputStream(source), new FileOutputStream(destination));
+ FileUtils.copy(new FileInputStream(sourceLocation), new FileOutputStream(targetLocation));
2843ed1
to
5b9f752
Compare
ce95362
to
183c24b
Compare
eea19ec
to
edb9b80
Compare
35daec7
to
51ec3e4
Compare
ecc4b42
to
91833d0
Compare
07e4213
to
9961675
Compare
0600257
to
25d96d6
Compare
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.