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


Java FileUtils.openInputStream方法代码示例

本文整理汇总了Java中org.apache.commons.io.FileUtils.openInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.openInputStream方法的具体用法?Java FileUtils.openInputStream怎么用?Java FileUtils.openInputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.io.FileUtils的用法示例。


在下文中一共展示了FileUtils.openInputStream方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: properties2Xml

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * Properties 转换 string.xml
 *
 * @param file      properties文件
 * @param xmlCn     中文string.xml
 * @param xmlEn     英文string.xml
 */
public static void properties2Xml(File file, File xmlCn, File xmlEn) {
    try (FileInputStream in = FileUtils.openInputStream(file)){
        List<String> lines = FileUtils.readLines(file);
        // PrintUtils.list(lines);
        // Properties 并不遵循文件原来的顺序,所以采取读行的方式处理
        List<String> xmlLinesCn = new ArrayList<>(lines.size());
        List<String> xmlLinesEn = new ArrayList<>(lines.size());
        addHeader(xmlLinesCn);
        addHeader(xmlLinesEn);
        for(String line : lines){
            xmlLinesCn.add(itemXmlCn(line));
            xmlLinesEn.add(itemXmlEn(line));
        }
        addFooter(xmlLinesCn);
        addFooter(xmlLinesEn);
        FileUtils.deleteQuietly(xmlCn);
        FileUtils.writeLines(xmlCn, "UTF-8", xmlLinesCn);
        FileUtils.writeLines(xmlEn, "UTF-8", xmlLinesEn);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:linchaolong,项目名称:ExcelParser,代码行数:30,代码来源:Properties2Xml.java

示例2: openInputStream

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static FileInputStream openInputStream(File file) {
    try {
        return FileUtils.openInputStream(file);
    } catch (IOException e) {
        throw new RuntimeException("Problems opening file input stream for file: " + file, e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:GFileUtils.java

示例3: resolveEntity

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Deprecated
public InputSource resolveEntity(String publicId, String systemId) throws IOException {
  if (!isHttpUrlOK(systemId)) {
    URL dtdURL = getClass().getResource(CacheXml.LATEST_DTD_LOCATION);
    File dtd = new File(DistributionConfig.GEMFIRE_PREFIX + "dtd");
    FileUtils.copyURLToFile(dtdURL, dtd);
    InputSource inputSource = new InputSource(FileUtils.openInputStream(dtd));
    FileUtils.deleteQuietly(dtd);
    return inputSource;
  } else {
    return null;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:14,代码来源:DtdResolver.java

示例4: fetchProperties

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private static Properties fetchProperties(final String propertiesFilePath) {
    final Properties properties = new Properties();
    InputStream is = null;
    try {
        is = FileUtils.openInputStream(new File(propertiesFilePath));
        properties.load(is);
    } catch (Throwable cause) {
        // cause.printStackTrace(System.err);
    } finally {
        IOUtils.closeQuietly(is);
    }
    return properties;
}
 
开发者ID:alibaba,项目名称:jvm-sandbox,代码行数:14,代码来源:CoreConfigure.java

示例5: IabClient

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public IabClient(File ipFile,
                 File excludeUserAgentFile,
                 File includeUserAgentFile) throws IOException {
    try (InputStream ip = FileUtils.openInputStream(ipFile);
         InputStream excludeUserAgent = FileUtils.openInputStream(excludeUserAgentFile);
         InputStream includeUserAgent = FileUtils.openInputStream(includeUserAgentFile)) {
        init(ip, excludeUserAgent, includeUserAgent);
    }
}
 
开发者ID:snowplow,项目名称:iab-spiders-and-robots-java-client,代码行数:10,代码来源:IabClient.java

示例6: fromFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void fromFile(String bloomFilterFile) throws IOException {
    System.out.println("Loading bloom filter from file " + bloomFilterFile);
    FileInputStream is = FileUtils.openInputStream(new File(bloomFilterFile));
    filter = com.google.common.hash.BloomFilter.readFrom(is, Funnels.stringFunnel(Charset.forName("UTF-8")));
    System.out.println("Bloom filter with approximately " + filter.approximateElementCount() + " addresses loaded");
}
 
开发者ID:eztam-,项目名称:bitcoin-bruteforce,代码行数:7,代码来源:BloomFilter.java

示例7: loadConfig

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private static MediatorConfig loadConfig(String configPath) throws IOException, RoutingTable.RouteAlreadyMappedException {
    MediatorConfig config = new MediatorConfig();
    //MediatorFhirConfig config=new MediatorFhirConfig();

    if (configPath!=null) {
        Properties props = new Properties();
        File conf = new File(configPath);
        InputStream in = FileUtils.openInputStream(conf);
        props.load(in);
        IOUtils.closeQuietly(in);

        config.setProperties(props);
    } else {
        config.setProperties("mediator.properties");
    }

    config.setName(config.getProperty("mediator.name"));
    config.setServerHost(config.getProperty("mediator.host"));
    config.setServerPort( Integer.parseInt(config.getProperty("mediator.port")) );
    config.setRootTimeout(Integer.parseInt(config.getProperty("mediator.timeout")));


    config.setCoreHost(config.getProperty("core.host"));
    config.setCoreAPIUsername(config.getProperty("core.api.user"));
    config.setCoreAPIPassword(config.getProperty("core.api.password"));
    if (config.getProperty("core.api.port") != null) {
        config.setCoreAPIPort(Integer.parseInt(config.getProperty("core.api.port")));
    }

    config.setRoutingTable(buildRoutingTable());
    config.setStartupActors(buildStartupActorsConfig());

    InputStream regInfo = MediatorMain.class.getClassLoader().getResourceAsStream("mediator-registration-info.json");
    RegistrationConfig regConfig = new RegistrationConfig(regInfo);
    config.setRegistrationConfig(regConfig);

    if (config.getProperty("mediator.heartbeats")!=null && "true".equalsIgnoreCase(config.getProperty("mediator.heartbeats"))) {
        config.setHeartbeatsEnabled(true);
    }

    return config;
}
 
开发者ID:gerard-bisama,项目名称:DHIS2-fhir-lab-app,代码行数:43,代码来源:MediatorMain.java


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