MCPcopy Create free account
hub / github.com/annmuor/jnode / move

Method move

jnode-core/src/jnode/core/FileUtils.java:59–88  ·  view source on GitHub ↗

Замена File.renameTo @param source @param dest @param override @return

(File source, File dest, boolean override)

Source from the content-addressed store, hash-verified

57 * @return
58 */
59 public static boolean move(File source, File dest, boolean override) {
60 if (!source.exists()) {
61 return false;
62 }
63 if (dest.exists() && !override) {
64 return false;
65 }
66
67 try {
68 FileInputStream fis = new FileInputStream(source);
69 FileOutputStream fos = new FileOutputStream(dest);
70 int len = 0;
71 byte[] block = new byte[BLOCK_SIZE];
72 do {
73 len = fis.read(block);
74 if (len > 0) {
75 fos.write(block, 0, len);
76 }
77 } while (len > 0);
78 fos.close();
79 fis.close();
80 if (source.length() == dest.length()) {
81 source.delete();
82 return true;
83 }
84 } catch (IOException e) {
85 } catch (RuntimeException e) {
86 }
87 return false;
88 }
89
90 /**
91 * zip file

Callers 2

hatchFileMethod · 0.95
tossInboundDirectoryMethod · 0.95

Calls 4

existsMethod · 0.80
readMethod · 0.80
writeMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected