本文整理汇总了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);
}
示例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);
}
示例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) {
}
}
示例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) {
}
}
示例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());
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}