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

Use NIO helpers in FileUtils for copy/move/rename #1013

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

bertm
Copy link
Contributor

@bertm bertm commented Nov 30, 2024

Copy was implemented through InputStream/OutputStream. The OS will be perfectly capable of doing this, no need to read and write the individual bytes. Use NIO's Files.copy to perform the copy instead.

Rename and move had two separate implementations without a compelling difference (apart from renameTo being unable to move across filesystem boundaries). Unify the two implementations and use the NIO's Files.move to move the file atomically, or if that fails, non-atomically.

The OS will be perfectly capable of doing this, no need to read and
write the individual bytes.
Move and rename now follow the same flow, no need to differentiate
anymore. Deprecate `renameTo` and replace all of its occurrences with
the equivalent `moveTo`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant