当前位置: 首页>>代码示例>>Java>>正文


Java OpenOption类代码示例

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


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

示例1: write

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Override
public Path write(Path path,
                  String content,
                  Charset cs,
                  Set<? extends OpenOption> options,
                  FileAttribute<?>... attrs) throws IllegalArgumentException, IOException, UnsupportedOperationException {
    if (!authManager.authorize(toResource(path),
                               getUser())) {
        throw new SecurityException();
    }
    return service.write(path,
                         content,
                         cs,
                         options,
                         attrs);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:17,代码来源:IOSecurityService.java

示例2: setAttributes

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Override
public Path setAttributes(final Path path,
                          final FileAttribute<?>... attrs)
        throws UnsupportedOperationException, IllegalArgumentException, ClassCastException, IOException, SecurityException {
    checkNotNull("path",
                 path);
    if (Files.isDirectory(path)) {
        return internalCreateDirectory(path,
                                       true,
                                       attrs);
    }
    return write(path,
                 readAllBytes(path),
                 Collections.<OpenOption>emptySet(),
                 attrs);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:17,代码来源:IOServiceDotFileImpl.java

示例3: testNewFileChannelUnsupportedOp

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Test
public void testNewFileChannelUnsupportedOp() {
    final URI newRepo = URI.create("git://newfcrepo-name");

    provider.newFileSystem(newRepo,
                           EMPTY_ENV);

    final Path path = provider.getPath(URI.create("git://newfcrepo-name/file.txt"));

    final Set<? extends OpenOption> options = emptySet();
    try {
        provider.newFileChannel(path,
                                options);
        failBecauseExceptionWasNotThrown(UnsupportedOperationException.class);
    } catch (Exception e) {
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:18,代码来源:JGitFileSystemImplProviderUnsupportedOpTest.java

示例4: testNewAsynchronousFileChannelUnsupportedOp

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Test
public void testNewAsynchronousFileChannelUnsupportedOp() {
    final URI newRepo = URI.create("git://newasyncrepo-name");

    provider.newFileSystem(newRepo,
                           EMPTY_ENV);

    final Path path = provider.getPath(URI.create("git://newasyncrepo-name/file.txt"));

    final Set<? extends OpenOption> options = emptySet();
    try {
        provider.newAsynchronousFileChannel(path,
                                            options,
                                            null);
        failBecauseExceptionWasNotThrown(UnsupportedOperationException.class);
    } catch (Exception e) {
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:19,代码来源:JGitFileSystemImplProviderUnsupportedOpTest.java

示例5: newInputStream

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Override
public InputStream newInputStream(final Path path,
                                  final OpenOption... options)
        throws IllegalArgumentException, NoSuchFileException, IOException, SecurityException {
    checkNotNull("path",
                 path);
    final File file = path.toFile();
    if (!file.exists()) {
        throw new NoSuchFileException(file.toString());
    }
    try {
        return new FileInputStream(path.toFile());
    } catch (FileNotFoundException e) {
        throw new NoSuchFileException(e.getMessage());
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:17,代码来源:SimpleFileSystemProvider.java

示例6: newByteChannel

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Override
public SeekableByteChannel newByteChannel(final Path path,
                                          final Set<? extends OpenOption> options,
                                          final FileAttribute<?>... attrs)
        throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
    final File file = checkNotNull("path",
                                   path).toFile();

    if (file.exists()) {
        if (!shouldCreateOrOpenAByteChannel(options)) {
            throw new FileAlreadyExistsException(path.toString());
        }
    }

    try {
        if (options != null && options.contains(READ)) {
            return openAByteChannel(path);
        } else {
            return createANewByteChannel(file);
        }
    } catch (java.io.IOException e) {
        throw new IOException("Failed to open or create a byte channel.",
                              e);
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:26,代码来源:SimpleFileSystemProvider.java

示例7: setUp

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    final SimpleFileSystemProvider simpleFileSystemProvider = new SimpleFileSystemProvider();
    simpleFileSystemProvider.forceAsDefault();

    ioService = spy(new MockIOService() {

        @Override
        public Path get(URI uri) throws IllegalArgumentException, FileSystemNotFoundException, SecurityException {
            return simpleFileSystemProvider.getPath(uri);
        }

        @Override
        public InputStream newInputStream(Path path,
                                          OpenOption... openOptions) throws IllegalArgumentException, NoSuchFileException, UnsupportedOperationException, IOException, SecurityException {
            return getClass().getResourceAsStream(
                    path.toString().substring(path.toString().indexOf("test-classes") + "test-classes".length()));
        }
    });

    archiver = new Archiver(ioService);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:23,代码来源:ArchiverTest.java

示例8: newInputStream

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Override
public InputStream newInputStream(Path path,
                                  OpenOption... options) throws IllegalArgumentException, NoSuchFileException, UnsupportedOperationException, IOException, SecurityException {
    if (!authManager.authorize(toResource(path),
                               getUser())) {
        throw new SecurityException();
    }
    return service.newInputStream(path,
                                  options);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:11,代码来源:IOSecurityService.java

示例9: newOutputStream

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Override
public OutputStream newOutputStream(Path path,
                                    OpenOption... options) throws IllegalArgumentException, UnsupportedOperationException, IOException, SecurityException {
    if (!authManager.authorize(toResource(path),
                               getUser())) {
        throw new SecurityException();
    }
    return service.newOutputStream(path,
                                   options);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:11,代码来源:IOSecurityService.java

示例10: newByteChannel

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Override
public SeekableByteChannel newByteChannel(Path path,
                                          OpenOption... options) throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException {
    if (!authManager.authorize(toResource(path),
                               getUser())) {
        throw new SecurityException();
    }
    return service.newByteChannel(path,
                                  options);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:11,代码来源:IOSecurityService.java

示例11: newBufferedWriter

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Override
public BufferedWriter newBufferedWriter(Path path,
                                        Charset cs,
                                        OpenOption... options) throws IllegalArgumentException, IOException, UnsupportedOperationException, SecurityException {
    if (!authManager.authorize(toResource(path),
                               getUser())) {
        throw new SecurityException();
    }
    return service.newBufferedWriter(path,
                                     cs,
                                     options);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:13,代码来源:IOSecurityService.java

示例12: newByteChannel

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Override
public SeekableByteChannel newByteChannel(final Path path,
                                          final Set<? extends OpenOption> options,
                                          final FileAttribute<?>... attrs)
        throws IllegalArgumentException, UnsupportedOperationException,
        FileAlreadyExistsException, IOException, SecurityException {
    checkNotNull("path",
                 path);
    final Properties properties = new Properties();
    if (exists(dot(path))) {
        properties.load(newInputStream(dot(path)));
    }
    final FileAttribute<?>[] allAttrs = consolidate(properties,
                                                    attrs);

    final SeekableByteChannel result = Files.newByteChannel(path,
                                                            buildOptions(options),
                                                            allAttrs);

    if (isFileScheme(path)) {
        buildDotFile(path,
                     newOutputStream(dot(path)),
                     allAttrs);
    }

    return result;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:28,代码来源:IOServiceDotFileImpl.java

示例13: newBufferedWriter

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Override
public BufferedWriter newBufferedWriter(final Path path,
                                        final Charset cs,
                                        final OpenOption... options)
        throws IllegalArgumentException, IOException, UnsupportedOperationException, SecurityException {
    return Files.newBufferedWriter(path,
                                   cs,
                                   options);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:10,代码来源:AbstractIOService.java

示例14: write

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Override
public Path write(Path path,
                  byte[] bytes,
                  Map<String, ?> stringMap,
                  OpenOption... openOptions) throws IOException, UnsupportedOperationException, SecurityException {
    return null;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:8,代码来源:MockIOService.java

示例15: write

import org.uberfire.java.nio.file.OpenOption; //导入依赖的package包/类
@Override
public Path write(Path path,
                  String content,
                  Charset cs,
                  OpenOption... options) throws IllegalArgumentException, IOException, UnsupportedOperationException {
    return null;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:8,代码来源:MockIOService.java


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