org.uberfire.java.nio.file.Path.toFile()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.uberfire.java.nio.file.Path.toFile()方法的一些代码示例,展示了Path.toFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.toFile()方法的具体详情如下:
包路径:org.uberfire.java.nio.file.Path
类名称:Path
方法名:toFile

Path.toFile介绍

暂无

代码示例

代码示例来源:origin: org.uberfire/vfs-model

@Override
public long size() {
  if (fileLenght == -1) {
    fileLenght = path.toFile().length();
  }
  return fileLenght;
}

代码示例来源:origin: org.uberfire/vfs-model

GeneralFileAttributes(final Path path) {
  this.path = checkNotNull("path", path);
  this.lastModifiedTime = new FileTimeImpl(path.toFile().lastModified());
  this.isRegularFile = path.toFile().isFile();
  this.isDirectory = path.toFile().isDirectory();
  this.isHidden = path.toFile().isHidden();
  this.isExecutable = path.toFile().canExecute();
  this.isReadable = path.toFile().canRead();
}

代码示例来源:origin: org.uberfire/uberfire-nio2-fs

@Override
public boolean isHidden(final Path path) throws IllegalArgumentException, IOException, SecurityException {
  checkNotNull("path",
         path);
  return path.toFile().isHidden();
}

代码示例来源:origin: org.uberfire/uberfire-nio2-fs

@Override
public void createDirectory(final Path dir,
              final FileAttribute<?>... attrs)
    throws UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
  checkNotNull("dir",
         dir);
  final Path realDir = dir.toAbsolutePath();
  if (realDir.toFile().exists()) {
    throw new FileAlreadyExistsException(dir.toString());
  }
  realDir.toFile().mkdirs();
}

代码示例来源:origin: org.uberfire/vfs-fs

@Override
public void createDirectory(final Path dir, final FileAttribute<?>... attrs)
    throws UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
  checkNotNull("dir", dir);
  final Path realDir = dir.toAbsolutePath();
  if (realDir.toFile().exists()) {
    throw new FileAlreadyExistsException(dir.toString());
  }
  realDir.toFile().mkdirs();
}

代码示例来源:origin: org.uberfire/vfs-fs

@Override
public Path readSymbolicLink(final Path link)
    throws UnsupportedOperationException, NotLinkException, IOException, SecurityException {
  checkNotNull("link", link);
  if (!link.toFile().exists()) {
    throw new NotLinkException(link.toString());
  }
  throw new UnsupportedOperationException();
}

代码示例来源:origin: org.uberfire/uberfire-nio2-fs

@Override
public Path readSymbolicLink(final Path link)
    throws UnsupportedOperationException, NotLinkException, IOException, SecurityException {
  checkNotNull("link",
         link);
  if (!link.toFile().exists()) {
    throw new NotLinkException(link.toString());
  }
  throw new UnsupportedOperationException();
}

代码示例来源:origin: org.kie.workbench.services/kie-wb-common-compiler-service

public static void copyTree(Path source,
              Path target) throws IOException {
  FileUtils.copyDirectory(source.toFile(),
              target.toFile());
}

代码示例来源:origin: org.uberfire/uberfire-structure-backend

public static void copyTree(Path source,
              Path target) throws IOException {
  FileUtils.copyDirectory(source.toFile(),
              target.toFile());
}

代码示例来源:origin: org.uberfire/vfs-fs

@Override
public void createLink(final Path link, final Path existing)
    throws UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
  checkNotNull("link", link);
  checkNotNull("existing", existing);
  checkCondition("existing must already exists", existing.toFile().exists());
  checkCondition("link and target can't be same", !link.equals(existing));
  if (link.toFile().exists()) {
    throw new FileAlreadyExistsException(link.toString());
  }
  throw new UnsupportedOperationException();
}

代码示例来源:origin: org.uberfire/vfs-fs

@Override
public void delete(final Path path) throws NoSuchFileException, DirectoryNotEmptyException, IOException, SecurityException {
  checkNotNull("path", path);
  if (!path.toFile().exists()) {
    throw new NoSuchFileException(path.toString());
  }
  deleteIfExists(path);
}

代码示例来源:origin: org.uberfire/uberfire-nio2-fs

@Override
public void delete(final Path path,
          final DeleteOption... options) throws NoSuchFileException, DirectoryNotEmptyException, IOException, SecurityException {
  checkNotNull("path",
         path);
  if (!path.toFile().exists()) {
    throw new NoSuchFileException(path.toString());
  }
  deleteIfExists(path,
          options);
}

代码示例来源:origin: org.uberfire/uberfire-nio2-fs

@Test
public void checkDeleteIfExists() throws IOException {
  final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();
  final File tempFile = File.createTempFile("foo",
                       "bar");
  final Path path = GeneralPathImpl.newFromFile(fsProvider.getFileSystem(URI.create("file:///")),
                         tempFile);
  assertThat(path.toFile()).exists();
  assertThat(fsProvider.deleteIfExists(path)).isTrue();
  assertThat(path.toFile()).doesNotExist();
}

代码示例来源:origin: org.uberfire/uberfire-structure-backend

@After
public void tearDown() {
  if (tmpRoot != null) {
    TestUtil.rm(tmpRoot.toFile());
  }
}

代码示例来源:origin: org.uberfire/uberfire-nio2-fs

@Test
public void checkDeleteIfExistsNonExistent() {
  final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();
  final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")),
                       "/path/to/file.txt",
                       false);
  assertThat(path.toFile()).doesNotExist();
  assertThat(fsProvider.deleteIfExists(path)).isFalse();
  assertThat(path.toFile()).doesNotExist();
}

代码示例来源:origin: org.uberfire/uberfire-nio2-fs

@Test(expected = FileAlreadyExistsException.class)
public void newByteChannelFileAlreadyExists() throws IOException {
  final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();
  final File tempFile = File.createTempFile("foo",
                       "bar");
  final Path path = GeneralPathImpl.newFromFile(fsProvider.getFileSystem(URI.create("file:///")),
                         tempFile);
  assertThat(path.toFile()).exists();
  assertThat(path.toFile()).isEqualTo(tempFile);
  fsProvider.newByteChannel(path,
               null);
}

代码示例来源:origin: org.uberfire/uberfire-nio2-fs

@Test
public void checkDelete() throws IOException {
  final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();
  final File tempFile = File.createTempFile("foo",
                       "bar");
  final Path path = GeneralPathImpl.newFromFile(fsProvider.getFileSystem(URI.create("file:///")),
                         tempFile);
  assertThat(path.toFile()).exists();
  fsProvider.delete(path);
  assertThat(path.toFile()).doesNotExist();
}

代码示例来源:origin: org.uberfire/uberfire-nio2-fs

@Test(expected = FileAlreadyExistsException.class)
public void checkCreateDirectoryAlreadyExists() {
  final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();
  final String userBasedPath = System.getProperty("user.dir") + "/temp";
  final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")),
                       userBasedPath,
                       false);
  assertThat(path.toFile()).doesNotExist();
  fsProvider.createDirectory(path);
  assertThat(path.toFile()).exists();
  fsProvider.createDirectory(path);
}

代码示例来源:origin: org.uberfire/uberfire-nio2-fs

@Test(expected = org.uberfire.java.nio.IOException.class)
public void newByteChannelInvalidPath() {
  final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();
  final String userBasedPath = System.getProperty("user.dir") + "path/to/some_file_here.txt";
  final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")),
                       userBasedPath,
                       false);
  assertThat(path.toFile()).doesNotExist();
  fsProvider.newByteChannel(path,
               null);
}

代码示例来源:origin: org.uberfire/uberfire-nio2-fs

@Test(expected = NoSuchFileException.class)
public void checkDeleteNonExistent() {
  final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider();
  final Path path = GeneralPathImpl.create(fsProvider.getFileSystem(URI.create("file:///")),
                       "/path/to/file.txt",
                       false);
  assertThat(path.toFile()).doesNotExist();
  fsProvider.delete(path);
}

相关文章