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


Java IOUtils.copyStream方法代码示例

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


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

示例1: testURLHandlerService

import org.jboss.gravia.utils.IOUtils; //导入方法依赖的package包/类
@Test
public void testURLHandlerService() throws Exception {

    try {
        new URL("foo://hi");
        Assert.fail("No handler registered. Should throw a MalformedURLException.");
    } catch (MalformedURLException mue) {
        // expected
    }

    Runtime runtime = RuntimeLocator.getRequiredRuntime();
    ModuleContext syscontext = runtime.getModuleContext();

    Dictionary<String, Object> props = new Hashtable<>();
    props.put(Constants.URL_HANDLER_PROTOCOL, "foo");
    ServiceRegistration<URLStreamHandler> sreg = syscontext.registerService(URLStreamHandler.class, new MyHandler(), props);

    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        IOUtils.copyStream(new URL("foo://somehost").openStream(), baos);
        Assert.assertEquals("somehost", new String(baos.toByteArray()));

        URL url = new URL("foo:///somepath");
        Assert.assertEquals("", url.getHost());
    } finally {
        sreg.unregister();
    }

    try {
        new URL("foo://hi").openConnection();
        Assert.fail("No handler registered any more.");
    } catch (IOException ex) {
        // expected
    }
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:36,代码来源:URLStreamHandlerTestBase.java

示例2: before

import org.jboss.gravia.utils.IOUtils; //导入方法依赖的package包/类
@Before
public void before() throws Exception {
    FileUtils.deleteDirectory(REPO_PATH);
    REPO_PATH.toFile().mkdirs();

    File configFile = REPO_PATH.resolve("repository-simple-security.xml").toFile();
    InputStream input = getClass().getClassLoader().getResourceAsStream("jcr/repository-simple-security.xml");
    try (OutputStream output = new FileOutputStream(configFile)) {
        IOUtils.copyStream(input, output);
    }

    repository = new TransientRepository(configFile, REPO_PATH.toFile());
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:14,代码来源:JcrIntegrationTest.java

示例3: getByteArrayPayload

import org.jboss.gravia.utils.IOUtils; //导入方法依赖的package包/类
public byte[] getByteArrayPayload(String resName) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (InputStream ins = getClass().getClassLoader().getResourceAsStream(resName)) {
        IOUtils.copyStream(ins, baos);
    }
    return baos.toByteArray();
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:8,代码来源:ASN1DataFormatIntegrationTest.java

示例4: getResourceValue

import org.jboss.gravia.utils.IOUtils; //导入方法依赖的package包/类
public static String getResourceValue (Class<?> clazz, String resname) throws IOException {
    try (InputStream in = clazz.getResourceAsStream(resname)) {
        IllegalStateAssertion.assertNotNull(in, "Cannot find resource: " + resname);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        IOUtils.copyStream(in, out);
        return new String(out.toByteArray());
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:9,代码来源:TestUtils.java

示例5: testURLHandlerService

import org.jboss.gravia.utils.IOUtils; //导入方法依赖的package包/类
@Test
public void testURLHandlerService() throws Exception {

    try {
        new URL("foo://hi");
        Assert.fail("No handler registered. Should throw a MalformedURLException.");
    } catch (MalformedURLException mue) {
        // expected
    }

    Runtime runtime = RuntimeLocator.getRequiredRuntime();
    ModuleContext syscontext = runtime.getModuleContext();

    Dictionary<String, Object> props = new Hashtable<>();
    props.put(Constants.URL_HANDLER_PROTOCOL, "foo");
    ServiceRegistration<URLStreamHandler> sreg = syscontext.registerService(URLStreamHandler.class, new MyHandler(), props);

    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        IOUtils.copyStream(new URL("foo://somehost").openStream(), baos);
        Assert.assertEquals("somehost", new String(baos.toByteArray()));
    } finally {
        sreg.unregister();
    }

    try {
        new URL("foo://hi").openConnection();
        Assert.fail("No handler registered any more.");
    } catch (IOException ex) {
        // expected
    }
}
 
开发者ID:tdiesler,项目名称:gravia,代码行数:33,代码来源:URLStreamHandlerTest.java

示例6: readCustomerXml

import org.jboss.gravia.utils.IOUtils; //导入方法依赖的package包/类
private String readCustomerXml(String xmlpath) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    IOUtils.copyStream(getClass().getResourceAsStream(xmlpath), out);
    return new String(out.toByteArray());
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:6,代码来源:XSLTTransformTest.java


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