Cleanup: use try-with-resources.

This commit is contained in:
Dennis Guse
2025-12-06 08:23:02 +01:00
parent 1cb3db496a
commit 7cb97b0e6b
4 changed files with 49 additions and 59 deletions
@@ -189,16 +189,10 @@ public class FileUtils {
return name;
}
/**
* Copy a File (src) to a File (dst).
*
* @param src source file.
* @param dst destination file.
*/
public static void copy(FileDescriptor src, File dst) {
try (FileChannel in = new FileInputStream(src).getChannel();
FileChannel out = new FileOutputStream(dst).getChannel()) {
in.transferTo(0, in.size(), out);
try (FileInputStream in = new FileInputStream(src);
FileOutputStream out = new FileOutputStream(dst)) {
in.getChannel().transferTo(0, in.getChannel().size(), out.getChannel());
} catch (Exception e) {
// post to log
Log.e(TAG, e.getMessage());