本文整理汇总了Java中org.uberfire.java.nio.file.StandardOpenOption类的典型用法代码示例。如果您正苦于以下问题:Java StandardOpenOption类的具体用法?Java StandardOpenOption怎么用?Java StandardOpenOption使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StandardOpenOption类属于org.uberfire.java.nio.file包,在下文中一共展示了StandardOpenOption类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReadNewByteChannel
import org.uberfire.java.nio.file.StandardOpenOption; //导入依赖的package包/类
@Test
public void testReadNewByteChannel() throws IOException {
final Path file = getFilePath();
ioService().deleteIfExists(file);
assertFalse(ioService().exists(file));
String content = "sample content";
ioService.write(file,
content);
assertTrue(ioService().exists(file));
final SeekableByteChannel sbc = ioService().newByteChannel(file,
StandardOpenOption.READ);
String readContent = readSbc(sbc);
sbc.close();
assertEquals(content,
readContent);
ioService().delete(file);
}
示例2: fillIndexBuilder
import org.uberfire.java.nio.file.StandardOpenOption; //导入依赖的package包/类
@Override
public DefaultIndexBuilder fillIndexBuilder(final Path path) throws Exception {
InputStream inputStream = null;
try {
inputStream = ioService.newInputStream(path,
StandardOpenOption.READ);
final String drl = DecisionTableFactory.loadFromInputStream(inputStream,
null);
return fillDrlIndexBuilder(path, drl);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
// no-op
}
}
}
}
示例3: load
import org.uberfire.java.nio.file.StandardOpenOption; //导入依赖的package包/类
@Override
public InputStream load( final Path path,
final String sessionId ) {
try {
final InputStream inputStream = ioService.newInputStream( Paths.convert( path ),
StandardOpenOption.READ );
//Signal opening to interested parties
resourceOpenedEvent.fire( new ResourceOpenedEvent( path,
getSessionInfo( sessionId ) ) );
return inputStream;
} catch ( Exception e ) {
throw ExceptionUtilities.handleException( e );
}
}
示例4: getSource
import org.uberfire.java.nio.file.StandardOpenOption; //导入依赖的package包/类
@Override
public String getSource( final Path path ) {
InputStream inputStream = null;
try {
final SpreadsheetCompiler compiler = new SpreadsheetCompiler();
inputStream = ioService.newInputStream( Paths.convert( path ),
StandardOpenOption.READ );
final String drl = compiler.compile( inputStream,
InputType.XLS );
return drl;
} catch ( Exception e ) {
throw new SourceGenerationFailedException( e.getMessage() );
} finally {
if ( inputStream != null ) {
try {
inputStream.close();
} catch ( IOException ioe ) {
throw ExceptionUtilities.handleException( ioe );
}
}
}
}
示例5: load
import org.uberfire.java.nio.file.StandardOpenOption; //导入依赖的package包/类
@Override
public InputStream load( final Path path,
final String sessionId ) {
try {
final InputStream inputStream = ioService.newInputStream( Paths.convert( path ),
StandardOpenOption.READ );
//Signal opening to interested parties
resourceOpenedEvent.fire( new ResourceOpenedEvent( path,
getSessionInfo( sessionId ) ) );
return inputStream;
} catch ( Exception e ) {
throw ExceptionUtilities.handleException( e );
}
}
示例6: prepareForReading
import org.uberfire.java.nio.file.StandardOpenOption; //导入依赖的package包/类
public void prepareForReading() throws IOException {
reader = ioService.newByteChannel(path,
StandardOpenOption.READ);
currentCursorReadPosition = reader.size() - 1;
}
示例7: write
import org.uberfire.java.nio.file.StandardOpenOption; //导入依赖的package包/类
public void write(Path pom,
CompilationRequest request) {
try {
Model model = reader.read(new ByteArrayInputStream(Files.readAllBytes(pom)));
if (model == null) {
logger.error("Model null from pom file:",
pom.toString());
return;
}
PomPlaceHolder pomPH = new PomPlaceHolder(pom.toAbsolutePath().toString(),
model.getArtifactId(),
model.getGroupId(),
model.getVersion(),
model.getPackaging(),
Files.readAllBytes(Paths.get(pom.toAbsolutePath().toString())));
if (!history.contains(pomPH)) {
PluginPresents plugs = updatePom(model);
request.getInfo().lateAdditionKiePluginPresent(plugs.isKiePluginPresent());
if (plugs.isKiePluginPresent()) {
String args[] = addCreateClasspathMavenArgs(request.getKieCliRequest().getArgs());
request.getKieCliRequest().setArgs(args);
}
if (plugs.pomOverwriteRequired()) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writer.write(baos,
model);
if (logger.isDebugEnabled()) {
logger.debug("Pom changed:{}",
new String(baos.toByteArray(),
StandardCharsets.UTF_8));
}
Path pomParent = Paths.get(pom.getParent().toAbsolutePath().toString(),
POM_NAME);
Files.delete(pomParent);
Files.write(pomParent,
baos.toByteArray(),
StandardOpenOption.CREATE_NEW);//enhanced pom
}
history.add(pomPH);
}
} catch (Exception e) {
logger.error(e.getMessage());
}
}