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