當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。