Замена File.renameTo @param source @param dest @param override @return
(File source, File dest, boolean override)
| 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 |