List of usage examples for org.apache.commons.io FileUtils openInputStream
public static FileInputStream openInputStream(File file) throws IOException
new FileInputStream(file)
. From source file:org.ado.minesync.minecraft.MinecraftWorldManagerTest.java
private FileInputStream getWorldStream(String worldPath) throws IOException { return FileUtils.openInputStream(new File(worldPath)); }
From source file:org.alternativevision.gpx.GPXParser.java
public GPX parseGPX(File gpxFile) throws IOException, ParserConfigurationException, SAXException, IOException { InputStream in = FileUtils.openInputStream(gpxFile); GPX gpx = parseGPX(in);/*from www. j av a2 s .c o m*/ in.close(); return gpx; }
From source file:org.apache.camel.component.schematron.SchematronEndpoint.java
@Override protected void doStart() throws Exception { super.doStart(); if (rules == null) { try {/*from w w w. java 2 s . c o m*/ // Attempt to read the schematron rules from the class path first. logger.debug("Reading schematron rules from class path {}", path); InputStream schRules = ResourceHelper .resolveMandatoryResourceAsInputStream(getCamelContext().getClassResolver(), path); rules = TemplatesFactory.newInstance().newTemplates(schRules); } catch (Exception e) { // Attempts from the file system. logger.debug("Schamatron rules not found in class path, attempting file system {}", path); InputStream schRules = FileUtils.openInputStream(new File(path)); rules = TemplatesFactory.newInstance().newTemplates(schRules); } // rules not found in class path nor in file system. if (rules == null) { logger.warn("Schematron rules not found {}", path); throw new SchematronConfigException("Failed to load rules: " + path); } } }
From source file:org.apache.druid.segment.realtime.firehose.LocalFirehoseFactory.java
@Override protected InputStream openObjectStream(File object) throws IOException { return FileUtils.openInputStream(object); }
From source file:org.apache.geode.management.internal.configuration.utils.DtdResolver.java
@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);/*from w ww. j a va 2s .c o m*/ return inputSource; } else { return null; } }
From source file:org.apache.gobblin.crypto.GPGFileDecryptorTest.java
@Test(enabled = false) public void keyBasedDecryptionTest() throws IOException { try (InputStream is = GPGFileDecryptor.decryptFile( FileUtils.openInputStream(new File(fileDir, keyBasedFile)), FileUtils.openInputStream(new File(fileDir, privateKey)), passPhrase)) { Assert.assertEquals(IOUtils.toString(is, Charsets.UTF_8), expectedKeyFileContent); }/*from ww w . ja v a 2 s . com*/ }
From source file:org.apache.gobblin.crypto.GPGFileDecryptorTest.java
@Test(enabled = false) public void passwordBasedDecryptionTest() throws IOException { try (InputStream is = GPGFileDecryptor .decryptFile(FileUtils.openInputStream(new File(fileDir, passwdBasedFile)), passPhrase)) { Assert.assertEquals(IOUtils.toString(is, Charsets.UTF_8), expectedPasswdFileContent); }//from w w w .ja v a2 s . c om }
From source file:org.apache.hadoop.gateway.GatewayFuncTestDriver.java
public InputStream getResourceStream(String resource) throws IOException { InputStream stream = null;/*w w w. ja va2 s . com*/ if (resource.startsWith("file:/")) { try { stream = FileUtils.openInputStream(new File(new URI(resource))); } catch (URISyntaxException e) { throw new IOException(e); } } else { stream = ClassLoader.getSystemResourceAsStream(getResourceName(resource)); } assertThat("Failed to find test resource " + resource, stream, Matchers.notNullValue()); return stream; }
From source file:org.apache.hadoop.gateway.services.topology.impl.DefaultTopologyService.java
private Topology loadTopologyAttempt(File file) throws IOException, SAXException, URISyntaxException { Topology topology;//w w w . j av a 2 s . co m Digester digester = digesterLoader.newDigester(); TopologyBuilder topologyBuilder = digester.parse(FileUtils.openInputStream(file)); if (null == topologyBuilder) { return null; } topology = topologyBuilder.build(); topology.setUri(file.toURI()); topology.setName(FilenameUtils.removeExtension(file.getName())); topology.setTimestamp(file.lastModified()); return topology; }
From source file:org.apache.jackrabbit.harness.compatibility.AbstractRepositoryTest.java
protected void doCreateRepositories(String name) throws Exception { // Create a repository using the Jackrabbit default configuration doCreateRepository(name, RepositoryImpl.class.getResourceAsStream("repository.xml")); // Create repositories for any special configurations included File directory = new File(new File("src", "test"), "resources"); File[] files = directory.listFiles(); if (files != null) { Arrays.sort(files);/*www . j ava 2 s. c om*/ for (File file : files) { String xml = file.getName(); if (file.isFile() && xml.endsWith(".xml")) { doCreateRepository(name + "-" + xml.substring(0, xml.length() - 4), FileUtils.openInputStream(file)); } } } }