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