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


Java StandardOpenOption类代码示例

本文整理汇总了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);
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:21,代码来源:CommonIOServiceDotFileTest.java

示例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
            }
        }
    }
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:21,代码来源:DecisionTableXLSFileIndexer.java

示例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 );
    }
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:17,代码来源:DecisionTableXLSServiceImpl.java

示例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 );
            }
        }
    }
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:23,代码来源:DecisionTableXLSServiceImpl.java

示例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 );
    }
}
 
开发者ID:kiegroup,项目名称:drools-wb,代码行数:18,代码来源:ScoreCardXLSServiceImpl.java

示例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;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:6,代码来源:SocialFile.java

示例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());
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:50,代码来源:DefaultPomEditor.java


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