@Override public void delete() { base.delete(); }
/** * Delete a file or directory if it exists. * Directories may only be deleted if they are empty. * This method is similar to Java 7 * <code>java.nio.file.Path.deleteIfExists</code>. * * @param path the file or directory name */ public static void delete(String path) { FilePath.get(path).delete(); }
/** * Try to delete a file or directory (ignoring errors). * * @param path the file or directory name * @return true if it worked */ public static boolean tryDelete(String path) { try { FilePath.get(path).delete(); return true; } catch (Exception e) { return false; } }
@Override public void delete() { for (int i = 0;; i++) { FilePath f = getBase(i); if (f.exists()) { f.delete(); } else { break; } } }
@Override public FileChannel truncate(long newLength) throws IOException { if (newLength >= length) { return this; } filePointer = Math.min(filePointer, newLength); int newFileCount = 1 + (int) (newLength / maxLength); if (newFileCount < list.length) { // delete some of the files FileChannel[] newList = new FileChannel[newFileCount]; // delete backwards, so that truncating is somewhat transactional for (int i = list.length - 1; i >= newFileCount; i--) { // verify the file is writable list[i].truncate(0); list[i].close(); try { file.getBase(i).delete(); } catch (DbException e) { throw DbException.convertToIOException(e); } } System.arraycopy(list, 0, newList, 0, newList.length); list = newList; } long size = newLength - maxLength * (newFileCount - 1); list[list.length - 1].truncate(size); this.length = newLength; return this; }
try { file = FilePath.get(fileName).open("r"); FilePath.get(fileName + ".temp").delete(); target = FilePath.get(fileName + ".temp").open("rw"); long fileSize = file.size();
@Override public void delete() { base.delete(); }
@Override public void delete() { base.delete(); }
/** * Delete a file or directory if it exists. * Directories may only be deleted if they are empty. * This method is similar to Java 7 * <code>java.nio.file.Path.deleteIfExists</code>. * * @param path the file or directory name */ public static void delete(String path) { FilePath.get(path).delete(); }
/** * Delete a file or directory if it exists. * Directories may only be deleted if they are empty. * This method is similar to Java 7 * <code>java.nio.file.Path.deleteIfExists</code>. * * @param path the file or directory name */ public static void delete(String path) { FilePath.get(path).delete(); }
/** * Try to delete a file or directory (ignoring errors). * * @param path the file or directory name * @return true if it worked */ public static boolean tryDelete(String path) { try { FilePath.get(path).delete(); return true; } catch (Exception e) { return false; } }
/** * Try to delete a file or directory (ignoring errors). * * @param path the file or directory name * @return true if it worked */ public static boolean tryDelete(String path) { try { FilePath.get(path).delete(); return true; } catch (Exception e) { return false; } }
@Override public void delete() { for (int i = 0;; i++) { FilePath f = getBase(i); if (f.exists()) { f.delete(); } else { break; } } }
@Override public void delete() { for (int i = 0;; i++) { FilePath f = getBase(i); if (f.exists()) { f.delete(); } else { break; } } }
@Override public FileChannel truncate(long newLength) throws IOException { if (newLength >= length) { return this; } filePointer = Math.min(filePointer, newLength); int newFileCount = 1 + (int) (newLength / maxLength); if (newFileCount < list.length) { // delete some of the files FileChannel[] newList = new FileChannel[newFileCount]; // delete backwards, so that truncating is somewhat transactional for (int i = list.length - 1; i >= newFileCount; i--) { // verify the file is writable list[i].truncate(0); list[i].close(); try { file.getBase(i).delete(); } catch (DbException e) { throw DbException.convertToIOException(e); } } System.arraycopy(list, 0, newList, 0, newList.length); list = newList; } long size = newLength - maxLength * (newFileCount - 1); list[list.length - 1].truncate(size); this.length = newLength; return this; }
@Override public FileChannel truncate(long newLength) throws IOException { if (newLength >= length) { return this; } filePointer = Math.min(filePointer, newLength); int newFileCount = 1 + (int) (newLength / maxLength); if (newFileCount < list.length) { // delete some of the files FileChannel[] newList = new FileChannel[newFileCount]; // delete backwards, so that truncating is somewhat transactional for (int i = list.length - 1; i >= newFileCount; i--) { // verify the file is writable list[i].truncate(0); list[i].close(); try { file.getBase(i).delete(); } catch (DbException e) { throw DbException.convertToIOException(e); } } System.arraycopy(list, 0, newList, 0, newList.length); list = newList; } long size = newLength - maxLength * (newFileCount - 1); list[list.length - 1].truncate(size); this.length = newLength; return this; }
try { file = FilePath.get(fileName).open("r"); FilePath.get(fileName + ".temp").delete(); target = FilePath.get(fileName + ".temp").open("rw"); long fileSize = file.size();
try { file = FilePath.get(fileName).open("r"); FilePath.get(fileName + ".temp").delete(); target = FilePath.get(fileName + ".temp").open("rw"); long fileSize = file.size();