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


Java IOUtils类代码示例

本文整理汇总了Java中org.apache.axiom.attachments.utils.IOUtils的典型用法代码示例。如果您正苦于以下问题:Java IOUtils类的具体用法?Java IOUtils怎么用?Java IOUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getBuilder

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
/**
 * Creates an OMBuilder for a plain XML message.
 *
 * @param inStream   InputStream for a XML message
 * @param charSetEnc Character set encoding to be used
 * @return Handler to a OMBuilder implementation instance
 * @throws javax.xml.stream.XMLStreamException
 */
public static StAXBuilder getBuilder(InputStream inStream, String charSetEnc) throws XMLStreamException {
    XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc);
    try {
        return new StAXSOAPModelBuilder(xmlReader);
    } catch (OMException e) {
        log.info("OMException in getSOAPBuilder", e);
        try {
            log.info("Remaining input stream :[" +
                    new String(IOUtils.getStreamAsByteArray(inStream), charSetEnc) + "]");
        } catch (IOException e1) {
            // Nothing here?
        }
        throw e;
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-gateway-framework,代码行数:24,代码来源:XMLUtil.java

示例2: getSOAPBuilder

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
/**
 * Creates an OMBuilder for a SOAP message. Default character set encording is used.
 *
 * @param inStream InputStream for a SOAP message
 * @return Handler to a OMBuilder implementation instance
 * @throws javax.xml.stream.XMLStreamException
 */
public static StAXBuilder getSOAPBuilder(InputStream inStream) throws XMLStreamException {
    XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream);
    try {
        return new StAXSOAPModelBuilder(xmlReader);
    } catch (OMException e) {
        log.info("OMException in getSOAPBuilder", e);
        try {
            log.info("Remaining input stream :[" +
                    new String(IOUtils.getStreamAsByteArray(inStream) , "UTF-8") + "]");
        } catch (IOException e1) {
            // Nothing here?
        }
        throw e;
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-gateway-framework,代码行数:23,代码来源:XMLUtil.java

示例3: getBytes

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
/**
 * Get a specific entry's content as a byte array
 * 
 * @param in
 * @param resource
 * @return
 * @throws Exception
 */
private byte[] getBytes(InputStream in, String resource) throws Exception {
    ZipInputStream zin = new ZipInputStream(in);
    ZipEntry entry;
    String entryName;
    while ((entry = zin.getNextEntry()) != null) {
        entryName = entry.getName();
        if (entryName != null &&
                entryName.endsWith(resource)) {
            byte[] raw = IOUtils.getStreamAsByteArray(zin);
            zin.close();
            return raw;
        }
    }
    return null;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:24,代码来源:DeploymentClassLoader.java

示例4: getBuilder

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
/**
 * Creates an OMBuilder for a plain XML message.
 *
 * @param inStream   InputStream for a XML message
 * @param charSetEnc Character set encoding to be used
 * @return Handler to a OMBuilder implementation instance
 * @throws XMLStreamException
 */
public static StAXBuilder getBuilder(InputStream inStream, String charSetEnc)
        throws XMLStreamException {
    XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc);
    try {
        return new StAXSOAPModelBuilder(xmlReader);
    } catch (OMException e) {
        log.info("OMException in getSOAPBuilder", e);
        try {
            log.info("Remaining input stream :[" +
                     new String(IOUtils.getStreamAsByteArray(inStream), charSetEnc) + "]");
        } catch (IOException e1) {
            // Nothing here?
        }
        throw e;
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:25,代码来源:BuilderUtil.java

示例5: getSOAPBuilder

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
/**
 * Creates an OMBuilder for a SOAP message. Default character set encording is used.
 *
 * @param inStream InputStream for a SOAP message
 * @return Handler to a OMBuilder implementation instance
 * @throws XMLStreamException
 */
public static StAXBuilder getSOAPBuilder(InputStream inStream) throws XMLStreamException {
    XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream);
    try {
        return new StAXSOAPModelBuilder(xmlReader);
    } catch (OMException e) {
        log.info("OMException in getSOAPBuilder", e);
        try {
            log.info("Remaining input stream :[" +
                     new String(IOUtils.getStreamAsByteArray(inStream)) + "]");
        } catch (IOException e1) {
            // Nothing here?
        }
        throw e;
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:BuilderUtil.java

示例6: testretByteArray

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
/**
 * Auto generated test method
 */
public void testretByteArray() throws java.lang.Exception {


    byte[] input = new byte[]{(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF};
    ComplexDataTypesDocLitBareStub.RetByteArray req = new ComplexDataTypesDocLitBareStub.RetByteArray();
    req.setInByteArray(new DataHandler(new ByteArrayDataSource(input)));
    DataHandler ret = stub.retByteArray(req).get_return();
    byte[] bytes = IOUtils.getStreamAsByteArray(ret.getInputStream());
    assertTrue(Arrays.equals(bytes, input));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:14,代码来源:ComplexDataTypesDocLitBareTest.java

示例7: testretByteArray

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
/**
 * Auto generated test method
 */
public void testretByteArray() throws java.lang.Exception {


    byte[] input = new byte[]{(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF};
    DataHandler ret = stub.retByteArray(new DataHandler(new ByteArrayDataSource(input)));
    byte[] bytes = IOUtils.getStreamAsByteArray(ret.getInputStream());
    assertTrue(Arrays.equals(bytes, input));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:12,代码来源:ComplexDataTypesComplexDataTypesSOAP11Test.java

示例8: getStringFromDatahandler

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
/**
 * Converts the given .datahandler to a string
 *
 * @return string
 */
public static String getStringFromDatahandler(DataHandler dataHandler) {
    try {
        InputStream inStream;
        if (dataHandler == null) {
            return "";
        }
        inStream = dataHandler.getDataSource().getInputStream();
        byte[] data = IOUtils.getStreamAsByteArray(inStream);
        return Base64.encode(data);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:ConverterUtil.java

示例9: findResource

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
/**
 * Finds the resource with the specified name on the URL search path.
 *
 * @param resource the name of the resource
 * @return a <code>URL</code> for the resource, or <code>null</code>
 * if the resource could not be found.
 */
public URL findResource(String resource) {
    URL url = super.findResource(resource);
    if (url == null) {
        for (int i = 0; embedded_jars != null && i < embedded_jars.size(); i++) {
            String libjar_name = (String) embedded_jars.get(i);
            try {
                InputStream in = getJarAsStream(libjar_name);
                ZipInputStream zin = new ZipInputStream(in);
                ZipEntry entry;
                String entryName;
                while ((entry = zin.getNextEntry()) != null) {
                    entryName = entry.getName();
                    if (entryName != null &&
                            entryName.endsWith(resource)) {
                        byte[] raw = IOUtils.getStreamAsByteArray(zin);
                        return new URL("jar", "", -1, urls[0] + "!/" + libjar_name + "!/" + entryName,
                                new ByteUrlStreamHandler(raw));
                    }
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
    return url;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:34,代码来源:DeploymentClassLoader.java

示例10: findResources

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
/**
 * Returns an Enumeration of URLs representing all of the resources
 * on the URL search path having the specified name.
 *
 * @param resource the resource name
 * @exception IOException if an I/O exception occurs
 * @return an <code>Enumeration</code> of <code>URL</code>s
 */
public Enumeration findResources(String resource) throws IOException {
    ArrayList resources = new ArrayList();
    Enumeration e = super.findResources(resource);
    while (e.hasMoreElements()) {
        resources.add(e.nextElement());
    }
    for (int i = 0; embedded_jars != null && i < embedded_jars.size(); i++) {
        String libjar_name = (String) embedded_jars.get(i);
        try {
        InputStream in = getJarAsStream(libjar_name);
        ZipInputStream zin = new ZipInputStream(in);
        ZipEntry entry;
        String entryName;
            while ((entry = zin.getNextEntry()) != null) {
                entryName = entry.getName();
                if (entryName != null &&
                        entryName.endsWith(resource)) {
                    byte[] raw = IOUtils.getStreamAsByteArray(zin);
                    resources.add(new URL("jar", "", -1, urls[0] + "!/" + libjar_name + "!/" + entryName,
                            new ByteUrlStreamHandler(raw)));
                }
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
    return Collections.enumeration(resources);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:37,代码来源:DeploymentClassLoader.java

示例11: testSetBase64Content

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
@Validated @Test
public void testSetBase64Content() {
    try {
        MessageFactory factory = MessageFactory.newInstance();
        SOAPMessage msg = factory.createMessage();
        AttachmentPart ap = msg.createAttachmentPart();

        String urlString = "http://ws.apache.org/images/project-logo.jpg";
        if (isNetworkedResourceAvailable(urlString)) {
            URL url = new URL(urlString);
            DataHandler dh = new DataHandler(url);
            //Create InputStream from DataHandler's InputStream
            InputStream is = dh.getInputStream();

            byte buf[] = IOUtils.getStreamAsByteArray(is);
            //Setting Content via InputStream for image/jpeg mime type
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            Base64.encode(buf, 0, buf.length, bos);
            buf = bos.toByteArray();
            InputStream stream = new ByteArrayInputStream(buf);
            ap.setBase64Content(stream, "image/jpeg");

            //Getting Content.. should return InputStream object
            InputStream r = ap.getBase64Content();
            if (r != null) {
                if (r instanceof InputStream) {
                    //InputStream object was returned (ok)
                } else {
                    fail("Unexpected object was returned");
                }
            }
        }
    } catch (Exception e) {
        fail("Exception: " + e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:37,代码来源:AttachmentTest.java

示例12: testStore

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
@Test
public void testStore() throws Exception {
	String documentName = "protectedSites.xml";

	File f = new File(tempDir, documentName);
	assertFalse(f.exists());

	manager.storeDocument(documentName, IOUtils.getStreamAsByteArray(getInputStream(documentName)));
	assertTrue(f.exists());
}
 
开发者ID:CDS-INSPIRE,项目名称:InSpider,代码行数:11,代码来源:MetadataManagerTest.java

示例13: testValidateSchemaViolation

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
@Test
public void testValidateSchemaViolation() throws Exception {
	InputStream inputStream = getInputStream("protectedSitesSchemaViolation.xml");
	assertNotNull(inputStream);
	
	ValidationResult result = manager.validateDocument(IOUtils.getStreamAsByteArray(inputStream), MetadataDocumentType.DATASET);
	
	assertNotNull(result);
	assertEquals(ValidationResult.SCHEMA_VIOLATION, result);
}
 
开发者ID:CDS-INSPIRE,项目名称:InSpider,代码行数:11,代码来源:MetadataManagerTest.java

示例14: testValidateGmd

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
@Test
public void testValidateGmd() throws Exception {
	InputStream inputStream = getInputStream("protectedSites.xml");
	assertNotNull(inputStream);
	
	ValidationResult result = manager.validateDocument(IOUtils.getStreamAsByteArray(inputStream), MetadataDocumentType.DATASET);
	
	assertNotNull(result);
	assertEquals(ValidationResult.VALID, result);
}
 
开发者ID:CDS-INSPIRE,项目名称:InSpider,代码行数:11,代码来源:MetadataManagerTest.java

示例15: testValidateSrv

import org.apache.axiom.attachments.utils.IOUtils; //导入依赖的package包/类
@Test
public void testValidateSrv() throws Exception {
	InputStream inputStream = getInputStream("protectedSitesView.xml");
	assertNotNull(inputStream);
	
	ValidationResult result = manager.validateDocument(IOUtils.getStreamAsByteArray(inputStream), MetadataDocumentType.SERVICE);
	
	assertNotNull(result);
	assertEquals(ValidationResult.VALID, result);
}
 
开发者ID:CDS-INSPIRE,项目名称:InSpider,代码行数:11,代码来源:MetadataManagerTest.java


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