Package java.nio.file

Examples of java.nio.file.FileAlreadyExistsException


     * file already exists.
     */
    private static MappedByteBuffer createMappedBuffer(@Nonnull File file, int capacity, boolean newFile) {
        try {
            if (newFile && file.exists() && file.length() > 0) {
                throw new FileAlreadyExistsException(file.getPath());
            }
            return new RandomAccessFile(file, "rw").getChannel().
                    map(FileChannel.MapMode.READ_WRITE, 0, Character.SIZE / Byte.SIZE * capacity);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
View Full Code Here


     * file already exists.
     */
    private static MappedByteBuffer createMappedBuffer(@Nonnull File file, int capacity, boolean newFile) {
        try {
            if (newFile && file.exists() && file.length() > 0) {
                throw new FileAlreadyExistsException(file.getPath());
            }
            return new RandomAccessFile(file, "rw").getChannel().
                    map(FileChannel.MapMode.READ_WRITE, 0, Double.SIZE / Byte.SIZE * capacity);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
View Full Code Here

     * file already exists.
     */
    private static MappedByteBuffer createMappedBuffer(@Nonnull File file, int capacity, boolean newFile) {
        try {
            if (newFile && file.exists() && file.length() > 0) {
                throw new FileAlreadyExistsException(file.getPath());
            }
            return new RandomAccessFile(file, "rw").getChannel().
                    map(FileChannel.MapMode.READ_WRITE, 0, capacity);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
View Full Code Here

     * file already exists.
     */
    private static MappedByteBuffer createMappedBuffer(@Nonnull File file, int capacity, boolean newFile) {
        try {
            if (newFile && file.exists() && file.length() > 0) {
                throw new FileAlreadyExistsException(file.getPath());
            }
            return new RandomAccessFile(file, "rw").getChannel().
                    map(FileChannel.MapMode.READ_WRITE, 0, Long.SIZE / Byte.SIZE * capacity);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
View Full Code Here

     * file already exists.
     */
    private static MappedByteBuffer createMappedBuffer(@Nonnull File file, int capacity, boolean newFile) {
        try {
            if (newFile && file.exists() && file.length() > 0) {
                throw new FileAlreadyExistsException(file.getPath());
            }
            return new RandomAccessFile(file, "rw").getChannel().
                    map(FileChannel.MapMode.READ_WRITE, 0, Float.SIZE / Byte.SIZE * capacity);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
View Full Code Here

     * file already exists.
     */
    private static MappedByteBuffer createMappedBuffer(@Nonnull File file, int capacity, boolean newFile) {
        try {
            if (newFile && file.exists() && file.length() > 0) {
                throw new FileAlreadyExistsException(file.getPath());
            }
            return new RandomAccessFile(file, "rw").getChannel().
                    map(FileChannel.MapMode.READ_WRITE, 0, Short.SIZE / Byte.SIZE * capacity);
        } catch (IOException e) {
            throw new UncheckedIOException(e);
View Full Code Here

    logger.debug("Try creating a new folder '{}' on disk.", file.getName());
    try {
      // create the folder on disk
      File folder = FileUtil.getPath(networkManager.getSession().getRoot(), file).toFile();
      if (folder.exists()) {
        throw new FileAlreadyExistsException("Folder already exists");
      } else if (!folder.mkdir()) {
        existedBefore = true;
        throw new IOException("Folder could not be created");
      }
    } catch (IOException | NoSessionException e) {
View Full Code Here

    try {
      DirectoryEntry entry = lookUp(path, Options.NOFOLLOW_LINKS);

      if (entry.exists()) {
        if (failIfExists) {
          throw new FileAlreadyExistsException(path.toString());
        }

        // currently can only happen if getOrCreateFile doesn't find the file with the read lock
        // and then the file is created between when it releases the read lock and when it
        // acquires the write lock; so, very unlikely
View Full Code Here

        if (destEntry.file().equals(sourceFile)) {
          return;
        } else if (options.contains(REPLACE_EXISTING)) {
          destView.delete(destEntry, DeleteMode.ANY, dest);
        } else {
          throw new FileAlreadyExistsException(dest.toString());
        }
      }

      if (move && sameFileSystem) {
        // Real move on the same file system.
View Full Code Here

   * @throws FileAlreadyExistsException if this entry does not exist
   */
  public DirectoryEntry requireDoesNotExist(
      Path pathForException) throws FileAlreadyExistsException {
    if (exists()) {
      throw new FileAlreadyExistsException(pathForException.toString());
    }
    return this;
  }
View Full Code Here

TOP

Related Classes of java.nio.file.FileAlreadyExistsException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.