Libraryless. Click here for Pure Java version (10794L/59K).
1 | static File copyFile(File src, File dest) ctex {
|
2 | File destDir = dest.getAbsoluteFile().getParentFile(); |
3 | if (destDir != null) destDir.mkdirs(); |
4 | File tempFile = new File(dest.getPath() + "_temp"); |
5 | FileInputStream inputStream = new FileInputStream(src.getPath()); |
6 | FileOutputStream outputStream = newFileOutputStream(tempFile.getPath()); |
7 | try {
|
8 | copyStream(inputStream, outputStream); |
9 | inputStream.close(); |
10 | } finally {
|
11 | outputStream.close(); |
12 | } |
13 | try {
|
14 | java.nio.file.Files.move(tempFile.toPath(), dest.toPath(), |
15 | java.nio.file.StandardCopyOption.REPLACE_EXISTING, |
16 | java.nio.file.StandardCopyOption.ATOMIC_MOVE); |
17 | } catch (java.nio.file.AtomicMoveNotSupportedException e) {
|
18 | java.nio.file.Files.move(tempFile.toPath(), dest.toPath(), |
19 | java.nio.file.StandardCopyOption.REPLACE_EXISTING); |
20 | } |
21 | ret dest; |
22 | } |
download show line numbers debug dex old transpilations
Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1000843 |
| Snippet name: | copyFile - returns dest |
| Eternal ID of this version: | #1000843/5 |
| Text MD5: | 737755d9df996325d11666979337d988 |
| Transpilation MD5: | 5ad8d8c43f35f37b2454b7250494cb3d |
| Author: | stefan |
| Category: | |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2026-08-10 01:21:28 |
| Source code size: | 866 bytes / 22 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1565 / 2260 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |