• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AtomicMoveNotSupportedException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中java.nio.file.AtomicMoveNotSupportedException的典型用法代码示例。如果您正苦于以下问题:Java AtomicMoveNotSupportedException类的具体用法?Java AtomicMoveNotSupportedException怎么用?Java AtomicMoveNotSupportedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AtomicMoveNotSupportedException类属于java.nio.file包,在下文中一共展示了AtomicMoveNotSupportedException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testFileSystemExceptions

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
public void testFileSystemExceptions() throws IOException {
    for (FileSystemException ex : Arrays.asList(new FileSystemException("a", "b", "c"),
        new NoSuchFileException("a", "b", "c"),
        new NotDirectoryException("a"),
        new DirectoryNotEmptyException("a"),
        new AtomicMoveNotSupportedException("a", "b", "c"),
        new FileAlreadyExistsException("a", "b", "c"),
        new AccessDeniedException("a", "b", "c"),
        new FileSystemLoopException("a"))) {

        FileSystemException serialize = serialize(ex);
        assertEquals(serialize.getClass(), ex.getClass());
        assertEquals("a", serialize.getFile());
        if (serialize.getClass() == NotDirectoryException.class ||
            serialize.getClass() == FileSystemLoopException.class ||
            serialize.getClass() == DirectoryNotEmptyException.class) {
            assertNull(serialize.getOtherFile());
            assertNull(serialize.getReason());
        } else {
            assertEquals(serialize.getClass().toString(), "b", serialize.getOtherFile());
            assertEquals(serialize.getClass().toString(), "c", serialize.getReason());
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:ExceptionSerializationTests.java


示例2: move

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Override
public void move(Path source, Path target, CopyOption... options) throws IOException {
    HashSet<CopyOption> copyOptions = Sets.newHashSet(options);
    if (copyOptions.contains(StandardCopyOption.ATOMIC_MOVE)) {
        throw new AtomicMoveNotSupportedException(source.toString(), target.toString(),
            "ATOMIC_MOVE not supported yet");
    }
    if (Files.isDirectory(source)) {
        MCRPath src = MCRFileSystemUtils.checkPathAbsolute(source);
        MCRDirectory srcRootDirectory = getRootDirectory(src);
        if (srcRootDirectory.hasChildren()) {
            throw new IOException("Directory is not empty");
        }
    }
    copy(source, target, options);
    delete(source);
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:18,代码来源:MCRFileSystemProvider.java


示例3: copyIfLocked

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Override
public void copyIfLocked(final Path source, final Path target, final Mover mover) throws IOException {
  checkNotNull(source);
  checkNotNull(target);
  try {
    mover.accept(source, target);
  }
  catch (AtomicMoveNotSupportedException atomicMoveNotSupported) {
      throw atomicMoveNotSupported;
  }
  catch (FileSystemException e) { // NOSONAR
    // Windows can throw a FileSystemException on move or moveAtomic
    // if the file is in use; in this case, copy and attempt to delete
    // source
    log.warn("Using copy to move {} to {}", source, target);
    copy(source, target);
    try {
      delete(source);
    }
    catch (IOException deleteException) { // NOSONAR
      log.error("Unable to delete {} after move: {}", source, deleteException.getMessage());
    }
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:25,代码来源:SimpleFileOperations.java


示例4: temporaryBlobMoveFallback

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Test
public void temporaryBlobMoveFallback() throws Exception {
  final byte[] content = new byte[TEST_DATA_LENGTH];
  new Random().nextBytes(content);

  doThrow(new AtomicMoveNotSupportedException("", "", "")).when(fileOperations).moveAtomic(any(), any());

  final Blob blob = underTest.create(new ByteArrayInputStream(content), TEST_HEADERS);
  verifyMoveOperations(blob);

  final byte[] output = extractContent(blob);
  assertThat("data must survive", content, is(equalTo(output)));

  final BlobMetrics metrics = blob.getMetrics();
  assertThat("size must be calculated correctly", metrics.getContentSize(), is(equalTo((long) TEST_DATA_LENGTH)));
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:17,代码来源:FileBlobStoreIT.java


示例5: close

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Override
public void close() throws IOException {
  try {
    this.channel.position(0); // reset channel to beginning to compute full SHA1
    String calculatedSha1 = ZsyncUtil.computeSha1(this.channel);
    if (!this.sha1.equals(calculatedSha1)) {
      throw new ChecksumValidationIOException(this.sha1, calculatedSha1);
    }
    try {
      Files.move(this.tempPath, this.path, REPLACE_EXISTING, ATOMIC_MOVE);
    } catch (AtomicMoveNotSupportedException e) {
      Files.move(this.tempPath, this.path, REPLACE_EXISTING);
    }
    Files.setLastModifiedTime(this.path, fromMillis(this.mtime));
  } finally {
    this.channel.close();
    this.listener.close();
  }
}
 
开发者ID:salesforce,项目名称:zsync4j,代码行数:20,代码来源:OutputFileWriter.java


示例6: sauvegarde

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
public boolean sauvegarde(Object o) {
        if (this.getParentFile() != null && !this.getParentFile().exists()) {
            this.getParentFile().mkdirs();
        }
        
        IOMethod m;
        m = new JsonIO();
//        m = new GsonIO();
//        m = new Jackson();
        try {
            File security = new File(this.getParent()+Adresse.separatorChar+"."+this.getName());
            m.sauvegarde(security, o);
            if(!this.exists()) {this.createNewFile();}
            try {
                Files.move(security.toPath(), this.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
            } catch(AtomicMoveNotSupportedException ex) {
                Files.move(security.toPath(), this.toPath(), StandardCopyOption.REPLACE_EXISTING);
            }
            if(!security.delete()) {security.deleteOnExit();}
        } catch(Exception e) {
            Logger.getLogger(Adresse.class.getName()).log(Level.SEVERE, "adresse : "+this.getAbsolutePath(), e);
            DialogueBloquant.error("dialog file not saved");
            return false;
        }
        return true;
    }
 
开发者ID:Sharcoux,项目名称:MathEOS,代码行数:27,代码来源:Adresse.java


示例7: replaceFile

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
public synchronized static void replaceFile(final File sourceFile, final File destFile)
        throws IOException {
    if (sourceFile == null) {
        throw new NullPointerException("sourceFile");
    }
    if (destFile == null) {
        throw new NullPointerException("destFile");
    }
    Path sourcePath = Paths.get(sourceFile.getAbsolutePath());
    Path destPath = Paths.get(destFile.getAbsolutePath());
    try {
        Files.move(sourcePath, destPath, FileReplaceOptions);
    } catch (AtomicMoveNotSupportedException ex) {
        Files.move(sourcePath, destPath, FallbackFileReplaceOptions);
    }
}
 
开发者ID:fragmer,项目名称:ClassiCubeLauncher,代码行数:17,代码来源:PathUtil.java


示例8: rename

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
private static void rename(Path sourceFile, Path targetFile) throws IOException {
  try {
    Files.move(sourceFile, targetFile, StandardCopyOption.ATOMIC_MOVE);
  } catch (AtomicMoveNotSupportedException e) {
    LOG.warn("Atomic rename from '{}' to '{}' not supported", sourceFile, targetFile);
    Files.move(sourceFile, targetFile);
  }
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:9,代码来源:PluginCache.java


示例9: moveIntoPlace

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
private static void moveIntoPlace(final File from, final File to) throws IOException {
    try {
        move(from.toPath(), to.toPath(), ATOMIC_MOVE);
    } catch (final AtomicMoveNotSupportedException ex) {
        move(from.toPath(), to.toPath(), REPLACE_EXISTING);
    } finally {
        deleteIfExists(from.toPath());
    }
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:10,代码来源:CachedResource.java


示例10: move

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Override
public void move(Path srcpath, SecureDirectoryStream<Path> targetdir, Path targetpath) throws IOException {
    checkClosed();
    checkFileSystem(srcpath);
    checkFileSystem(targetpath);
    throw new AtomicMoveNotSupportedException(srcpath.toString(), targetpath.toString(),
        "Currently not implemented");
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:9,代码来源:MCRDirectoryStream.java


示例11: moveAtomic

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Override
public void moveAtomic(final Path source, final Path target) throws IOException {
  checkNotNull(source);
  checkNotNull(target);
  DirectoryHelper.mkdir(target.getParent());
  try {
    Files.move(source, target, StandardCopyOption.ATOMIC_MOVE);
  }
  catch (UnsupportedOperationException e) { // NOSONAR
    throw new AtomicMoveNotSupportedException(source.toString(), target.toString(), e.getMessage());
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:13,代码来源:SimpleFileOperations.java


示例12: overwriteAtomic

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Override
public void overwriteAtomic(final Path source, final Path target) throws IOException {
  checkNotNull(source);
  checkNotNull(target);
  DirectoryHelper.mkdir(target.getParent());
  try {
    Files.move(source, target, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
  }
  catch (UnsupportedOperationException e) { // NOSONAR
    throw new AtomicMoveNotSupportedException(source.toString(), target.toString(), e.getMessage());
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:13,代码来源:SimpleFileOperations.java


示例13: move

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
private void move(final Path source, final Path target) throws IOException {
  if (supportsAtomicMove) {
    try {
      fileOperations.copyIfLocked(source, target, fileOperations::moveAtomic);
      return;
    }
    catch (AtomicMoveNotSupportedException e) { // NOSONAR
      supportsAtomicMove = false;
      log.warn("Disabling atomic moves for blob store {}, could not move {} to {}, reason deleted: {}",
          blobStoreConfiguration.getName(), source, target, e.getReason());
    }
  }
  log.trace("Using normal move for blob store {}, moving {} to {}", blobStoreConfiguration.getName(), source, target);
  fileOperations.copyIfLocked(source, target, fileOperations::move);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:16,代码来源:FileBlobStore.java


示例14: overwrite

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
private void overwrite(final Path source, final Path target) throws IOException {
  if (supportsAtomicMove) {
    try {
      fileOperations.copyIfLocked(source, target, fileOperations::overwriteAtomic);
      return;
    }
    catch (AtomicMoveNotSupportedException e) { // NOSONAR
      supportsAtomicMove = false;
      log.warn("Disabling atomic moves for blob store {}, could not overwrite {} with {}, reason deleted: {}",
          blobStoreConfiguration.getName(), source, target, e.getReason());
    }
  }
  log.trace("Using normal overwrite for blob store {}, overwriting {} with {}", blobStoreConfiguration.getName(), source, target);
  fileOperations.copyIfLocked(source, target, fileOperations::overwrite);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:16,代码来源:FileBlobStore.java


示例15: temporaryBlobMoveFallbackPersists

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Test
public void temporaryBlobMoveFallbackPersists() throws Exception {
  final byte[] content = new byte[TEST_DATA_LENGTH];
  new Random().nextBytes(content);

  doThrow(new AtomicMoveNotSupportedException("", "", "")).when(fileOperations).moveAtomic(any(), any());

  underTest.create(new ByteArrayInputStream(content), TEST_HEADERS);
  underTest.create(new ByteArrayInputStream(content), TEST_HEADERS);

  verify(fileOperations, times(1)).moveAtomic(any(), any());
  verify(fileOperations, times(4)).move(any(), any());
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:14,代码来源:FileBlobStoreIT.java


示例16: atomicMoveWithFallback

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
/**
 * Move a file atomically, if it fails, it falls back to a non-atomic operation
 * @param from
 * @param to
 * @throws IOException
 */
private static void atomicMoveWithFallback(Path from, Path to) throws IOException
{
    try
    {
        Files.move(from, to, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
    }
    catch (AtomicMoveNotSupportedException e)
    {
        logger.debug("Could not do an atomic move", e);
        Files.move(from, to, StandardCopyOption.REPLACE_EXISTING);
    }

}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:FileUtils.java


示例17: move

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
static void move(Path source, Path target) throws IOException {
    try {
        Files.move(source, target, ATOMIC_MOVE, REPLACE_EXISTING);
    } catch (AtomicMoveNotSupportedException ex) {
        logger.debug(shortError, "-- move() - fallback, atomic move not supported: ", ex);
        Files.move(source, target, REPLACE_EXISTING);
    }
}
 
开发者ID:horrorho,项目名称:InflatableDonkey,代码行数:9,代码来源:AtomicWriter.java


示例18: move

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
@Override
public void move(String location) throws IOException {
    final Path source = Paths.get(getURI());
    final Path target = Paths.get(resolver.getResource(location).getURI());
    try {
        Files.move(source, target, REPLACE_EXISTING, ATOMIC_MOVE);
    } catch (AtomicMoveNotSupportedException e) {
        LOGGER.debug("Atomic move not supported, trying without it.", e);
        Files.move(source, target, REPLACE_EXISTING);
    }
}
 
开发者ID:Talend,项目名称:daikon,代码行数:12,代码来源:LocalDeletableResource.java


示例19: execute

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
void execute(Terminal terminal, String pluginName, Environment env) throws Exception {
    if (pluginName == null) {
        throw new UserException(ExitCodes.USAGE, "plugin name is required");
    }

    terminal.println("-> Removing " + Strings.coalesceToEmpty(pluginName) + "...");

    final Path pluginDir = env.pluginsFile().resolve(pluginName);
    if (Files.exists(pluginDir) == false) {
        throw new UserException(
                ExitCodes.CONFIG,
                "plugin " + pluginName + " not found; run 'elasticsearch-plugin list' to get list of installed plugins");
    }

    final List<Path> pluginPaths = new ArrayList<>();

    final Path pluginBinDir = env.binFile().resolve(pluginName);
    if (Files.exists(pluginBinDir)) {
        if (Files.isDirectory(pluginBinDir) == false) {
            throw new UserException(ExitCodes.IO_ERROR, "Bin dir for " + pluginName + " is not a directory");
        }
        pluginPaths.add(pluginBinDir);
        terminal.println(VERBOSE, "Removing: " + pluginBinDir);
    }

    terminal.println(VERBOSE, "Removing: " + pluginDir);
    final Path tmpPluginDir = env.pluginsFile().resolve(".removing-" + pluginName);
    try {
        Files.move(pluginDir, tmpPluginDir, StandardCopyOption.ATOMIC_MOVE);
    } catch (final AtomicMoveNotSupportedException e) {
        // this can happen on a union filesystem when a plugin is not installed on the top layer; we fall back to a non-atomic move
        Files.move(pluginDir, tmpPluginDir);
    }
    pluginPaths.add(tmpPluginDir);

    IOUtils.rm(pluginPaths.toArray(new Path[pluginPaths.size()]));

    // we preserve the config files in case the user is upgrading the plugin, but we print
    // a message so the user knows in case they want to remove manually
    final Path pluginConfigDir = env.configFile().resolve(pluginName);
    if (Files.exists(pluginConfigDir)) {
        terminal.println(
                "-> Preserving plugin config files [" + pluginConfigDir + "] in case of upgrade, delete manually if not needed");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:46,代码来源:RemovePluginCommand.java


示例20: move

import java.nio.file.AtomicMoveNotSupportedException; //导入依赖的package包/类
/**
 * Attempts to move the file represented by the specified {@link Path} to the specified destination atomically,
 * resorting to moving it non-atomically if atomic operations are not supported by the source or destination file
 * system.
 *
 * @param source The source path.
 * @param destination The destination path.
 * @throws IOException If the file could not be moved.
 */
public static void move(Path source, Path destination) throws IOException {
	try {
		Files.move(source, destination, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
	} catch (AtomicMoveNotSupportedException e) {
		Files.move(source, destination, StandardCopyOption.REPLACE_EXISTING);
	}
}
 
开发者ID:Major-,项目名称:Vicis,代码行数:17,代码来源:PathUtils.java



注:本文中的java.nio.file.AtomicMoveNotSupportedException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MetalLabelUI类代码示例发布时间:2022-05-21
下一篇:
Java Byte类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap