本文整理汇总了Java中com.sun.xml.internal.messaging.saaj.util.ByteOutputStream.write方法的典型用法代码示例。如果您正苦于以下问题:Java ByteOutputStream.write方法的具体用法?Java ByteOutputStream.write怎么用?Java ByteOutputStream.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.xml.internal.messaging.saaj.util.ByteOutputStream
的用法示例。
在下文中一共展示了ByteOutputStream.write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MimeBodyPart
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; //导入方法依赖的package包/类
/**
* Constructs a MimeBodyPart by reading and parsing the data from
* the specified input stream. The parser consumes data till the end
* of the given input stream. The input stream must start at the
* beginning of a valid MIME body part and must terminate at the end
* of that body part. <p>
*
* Note that the "boundary" string that delimits body parts must
* <strong>not</strong> be included in the input stream. The intention
* is that the MimeMultipart parser will extract each body part's bytes
* from a multipart stream and feed them into this constructor, without
* the delimiter strings.
*
* @param is the body part Input Stream
*/
public MimeBodyPart(InputStream is) throws MessagingException {
if (!(is instanceof ByteArrayInputStream) &&
!(is instanceof BufferedInputStream) &&
!(is instanceof SharedInputStream))
is = new BufferedInputStream(is);
headers = new InternetHeaders(is);
if (is instanceof SharedInputStream) {
SharedInputStream sis = (SharedInputStream) is;
contentStream = sis.newStream(sis.getPosition(), -1);
} else {
try {
ByteOutputStream bos = new ByteOutputStream();
bos.write(is);
content = bos.getBytes();
contentLength = bos.getCount();
} catch (IOException ioex) {
throw new MessagingException("Error reading input stream", ioex);
}
}
}
示例2: setBase64Content
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; //导入方法依赖的package包/类
public void setBase64Content(InputStream content, String contentType)
throws SOAPException {
if (mimePart != null) {
mimePart.close();
mimePart = null;
}
dataHandler = null;
InputStream decoded = null;
try {
decoded = MimeUtility.decode(content, "base64");
InternetHeaders hdrs = new InternetHeaders();
hdrs.setHeader("Content-Type", contentType);
//TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
// Ctor with inputStream causes problems based on the InputStream
// has markSupported()==true
ByteOutputStream bos = new ByteOutputStream();
bos.write(decoded);
rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
setMimeHeader("Content-Type", contentType);
} catch (Exception e) {
log.log(Level.SEVERE, "SAAJ0578.soap.attachment.setbase64content.exception", e);
throw new SOAPExceptionImpl(e.getLocalizedMessage());
} finally {
try {
decoded.close();
} catch (IOException ex) {
throw new SOAPException(ex);
}
}
}
示例3: setRawContent
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; //导入方法依赖的package包/类
public void setRawContent(InputStream content, String contentType)
throws SOAPException {
if (mimePart != null) {
mimePart.close();
mimePart = null;
}
dataHandler = null;
try {
InternetHeaders hdrs = new InternetHeaders();
hdrs.setHeader("Content-Type", contentType);
//TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
// Ctor with inputStream causes problems based on whether the InputStream has
// markSupported()==true or false
ByteOutputStream bos = new ByteOutputStream();
bos.write(content);
rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
setMimeHeader("Content-Type", contentType);
} catch (Exception e) {
log.log(Level.SEVERE, "SAAJ0576.soap.attachment.setrawcontent.exception", e);
throw new SOAPExceptionImpl(e.getLocalizedMessage());
} finally {
try {
content.close();
} catch (IOException ex) {
throw new SOAPException(ex);
}
}
}
示例4: writeTo
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; //导入方法依赖的package包/类
public void writeTo(OutputStream os)
throws IOException, MessagingException {
// inputStream was not null
if (in != null) {
contentType.setParameter("boundary", this.boundary);
}
String bnd = "--" + contentType.getParameter("boundary");
for (int i = 0; i < parts.size(); i++) {
OutputUtil.writeln(bnd, os); // put out boundary
((MimeBodyPart)parts.get(i)).writeTo(os);
OutputUtil.writeln(os); // put out empty line
}
if (in != null) {
OutputUtil.writeln(bnd, os); // put out boundary
if ((os instanceof ByteOutputStream) && lazyAttachments) {
((ByteOutputStream)os).write(in);
} else {
ByteOutputStream baos = new ByteOutputStream(in.available());
baos.write(in);
baos.writeTo(os);
// reset the inputstream so that we can support a
//getAttachment later
in = baos.newInputStream();
}
// this will endup writing the end boundary
} else {
// put out last boundary
OutputUtil.writeAsAscii(bnd, os);
OutputUtil.writeAsAscii("--", os);
}
}
示例5: getBytes
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; //导入方法依赖的package包/类
/**
*
* @deprecated
* this is an expensive operation that require an additional
* buffer reallocation just to get the array of an exact size.
* Unless you absolutely need the exact size array, don't use this.
* Use {@link ByteOutputStream} and {@link ByteOutputStream#write(InputStream)}.
*/
public static byte[] getBytes(InputStream is) throws IOException {
ByteOutputStream bos = new ByteOutputStream();
try {
bos.write(is);
} finally {
is.close();
}
return bos.toByteArray();
}
示例6: setBase64Content
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; //导入方法依赖的package包/类
public void setBase64Content(InputStream content, String contentType)
throws SOAPException {
if (mimePart != null) {
mimePart.close();
mimePart = null;
}
dataHandler = null;
InputStream decoded = null;
try {
decoded = MimeUtility.decode(content, "base64");
InternetHeaders hdrs = new InternetHeaders();
hdrs.setHeader("Content-Type", contentType);
//TODO: reading the entire attachment here is ineffcient. Somehow the MimeBodyPart
// Ctor with inputStream causes problems based on the InputStream
// has markSupported()==true
ByteOutputStream bos = new ByteOutputStream();
bos.write(decoded);
rawContent = new MimeBodyPart(hdrs, bos.getBytes(), bos.getCount());
setMimeHeader("Content-Type", contentType);
} catch (Exception e) {
log.log(Level.SEVERE, "SAAJ0578.soap.attachment.setbase64content.exception", e);
throw new SOAPExceptionImpl(e.getLocalizedMessage());
} finally {
try {
decoded.close();
} catch (IOException ex) {
throw new SOAPException(ex);
}
}
}