本文整理了Java中org.apache.commons.io.output.ByteArrayOutputStream.writeTo()
方法的一些代码示例,展示了ByteArrayOutputStream.writeTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteArrayOutputStream.writeTo()
方法的具体详情如下:
包路径:org.apache.commons.io.output.ByteArrayOutputStream
类名称:ByteArrayOutputStream
方法名:writeTo
[英]Writes the entire contents of this byte stream to the specified output stream.
[中]将此字节流的全部内容写入指定的输出流。
代码示例来源:origin: org.apache.commons/commons-io
/**
* Switches the underlying output stream from a memory based stream to one
* that is backed by disk. This is the point at which we realise that too
* much data is being written to keep in memory, so we elect to switch to
* disk-based storage.
*
* @exception IOException if an error occurs.
*/
protected void thresholdReached() throws IOException
{
FileOutputStream fos = new FileOutputStream(outputFile);
memoryOutputStream.writeTo(fos);
currentOutputStream = fos;
memoryOutputStream = null;
}
代码示例来源:origin: commons-io/commons-io
/**
* Writes the data from this output stream to the specified output stream,
* after it has been closed.
*
* @param out output stream to write to.
* @throws IOException if this stream is not yet closed or an error occurs.
*/
public void writeTo(final OutputStream out) throws IOException
{
// we may only need to check if this is closed if we are working with a file
// but we should force the habit of closing wether we are working with
// a file or memory.
if (!closed) {
throw new IOException("Stream not closed");
}
if (isInMemory()) {
memoryOutputStream.writeTo(out);
} else {
try (FileInputStream fis = new FileInputStream(outputFile)) {
IOUtils.copy(fis, out);
}
}
}
}
代码示例来源:origin: commons-io/commons-io
/**
* Switches the underlying output stream from a memory based stream to one
* that is backed by disk. This is the point at which we realise that too
* much data is being written to keep in memory, so we elect to switch to
* disk-based storage.
*
* @throws IOException if an error occurs.
*/
@Override
protected void thresholdReached() throws IOException
{
if (prefix != null) {
outputFile = File.createTempFile(prefix, suffix, directory);
}
FileUtils.forceMkdirParent(outputFile);
final FileOutputStream fos = new FileOutputStream(outputFile);
try {
memoryOutputStream.writeTo(fos);
} catch (final IOException e){
fos.close();
throw e;
}
currentOutputStream = fos;
memoryOutputStream = null;
}
代码示例来源:origin: org.apache.commons/commons-io
memoryOutputStream.writeTo(out);
代码示例来源:origin: jenkinsci/jenkins
private ByteArrayOutputStream encodeToBytes() throws IOException {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
try (OutputStream gzos = new GZIPOutputStream(buf);
ObjectOutputStream oos = JenkinsJVM.isJenkinsJVM() ? AnonymousClassWarnings.checkingObjectOutputStream(gzos) : new ObjectOutputStream(gzos)) {
oos.writeObject(this);
}
ByteArrayOutputStream buf2 = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(new Base64OutputStream(buf2,true,-1,null));
try {
buf2.write(PREAMBLE);
if (JenkinsJVM.isJenkinsJVM()) { // else we are in another JVM and cannot sign; result will be ignored unless INSECURE
byte[] mac = MAC.mac(buf.toByteArray());
dos.writeInt(- mac.length); // negative to differentiate from older form
dos.write(mac);
}
dos.writeInt(buf.size());
buf.writeTo(dos);
} finally {
dos.close();
}
buf2.write(POSTAMBLE);
return buf2;
}
代码示例来源:origin: commons-io/commons-io
ref.writeTo(baout1);
final java.io.ByteArrayOutputStream ref1 = new java.io.ByteArrayOutputStream();
baout.writeTo(ref1);
checkStreams(baout1, ref1);
代码示例来源:origin: Nextdoor/bender
public String produce(final OutputStream dataSink) throws Exception {
/*
* Note this is executed in a different thread
*/
payload.writeTo(dataSink);
return null;
}
};
代码示例来源:origin: Nextdoor/bender
public String produce(final OutputStream dataSink) throws Exception {
/*
* Note this is executed in a different thread
*/
payload.writeTo(dataSink);
return null;
}
};
代码示例来源:origin: org.tinygroup/org.tinygroup.weblayerbase
/**
* Switches the underlying output stream from a memory based stream to one
* that is backed by disk. This is the point at which we realise that too
* much data is being written to keep in memory, so we elect to switch to
* disk-based storage.
*
* @throws IOException if an error occurs.
*/
protected void thresholdReached() throws IOException {
ByteArrayOutputStream totalStream = new ByteArrayOutputStream();
memoryOutputStream.writeTo(totalStream);
currentOutputStream = totalStream;
memoryOutputStream = null;
}
代码示例来源:origin: org.tinygroup/weblayer
/**
* Switches the underlying output stream from a memory based stream to one
* that is backed by disk. This is the point at which we realise that too
* much data is being written to keep in memory, so we elect to switch to
* disk-based storage.
*
* @exception IOException
* if an error occurs.
*/
@Override
protected void thresholdReached() throws IOException {
ByteArrayOutputStream totalStream=new ByteArrayOutputStream();
memoryOutputStream.writeTo(totalStream);
currentOutputStream = totalStream;
memoryOutputStream = null;
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.io
/**
* Switches the underlying output stream from a memory based stream to one
* that is backed by disk. This is the point at which we realise that too
* much data is being written to keep in memory, so we elect to switch to
* disk-based storage.
*
* @exception IOException if an error occurs.
*/
protected void thresholdReached() throws IOException
{
if (prefix != null) {
outputFile = File.createTempFile(prefix, suffix, directory);
}
FileOutputStream fos = new FileOutputStream(outputFile);
memoryOutputStream.writeTo(fos);
currentOutputStream = fos;
memoryOutputStream = null;
}
代码示例来源:origin: com.atlassian.core/atlassian-core
/**
* Switches the underlying output stream from a memory based stream to one that is backed by disk. This is the point
* at which we realise that too much data is being written to keep in memory, so we elect to switch to disk-based
* storage.
*
* @throws IOException if an error occurs.
*/
protected void thresholdReached() throws IOException {
FileOutputStream fos = new FileOutputStream(getFile());
memoryOutputStream.writeTo(fos);
currentOutputStream = fos;
memoryOutputStream = null;
}
代码示例来源:origin: com.atlassian.core/atlassian-core-utils
/**
* Switches the underlying output stream from a memory based stream to one that is backed by disk. This is the point
* at which we realise that too much data is being written to keep in memory, so we elect to switch to disk-based
* storage.
*
* @throws IOException if an error occurs.
*/
protected void thresholdReached() throws IOException
{
FileOutputStream fos = new FileOutputStream(getFile());
memoryOutputStream.writeTo(fos);
currentOutputStream = fos;
memoryOutputStream = null;
}
代码示例来源:origin: apache/nifi-minifi
protected static void writeNiFiPropertiesFile(ByteArrayOutputStream nifiPropertiesOutputStream, String destPath) throws IOException {
final Path nifiPropertiesPath = Paths.get(destPath, "nifi.properties");
try (FileOutputStream nifiProperties = new FileOutputStream(nifiPropertiesPath.toString())) {
nifiPropertiesOutputStream.writeTo(nifiProperties);
} finally {
if (nifiPropertiesOutputStream != null) {
nifiPropertiesOutputStream.flush();
nifiPropertiesOutputStream.close();
}
}
}
代码示例来源:origin: apache/fop
private void commit(byte functionType) throws IOException {
int length = baout.size() + 2;
assert length < 256;
OutputStream out = getOutputStreamForControlSequence(length);
out.write(length);
out.write(functionType);
baout.writeTo(out);
}
代码示例来源:origin: yrom/shrinker
@Override
public void proceed() {
try {
List<Pair<String, byte[]>> entryList = readZipEntries(src)
.parallelStream()
.map(this::transformClassBlob)
.collect(Collectors.toList());
if (entryList.isEmpty()) return;
try (OutputStream fileOut = Files.newOutputStream(dst)) {
ByteArrayOutputStream buffer = zipEntries(entryList);
buffer.writeTo(fileOut);
}
} catch (IOException e) {
throw new RuntimeException("Reading jar entries failure", e);
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
private ByteArrayOutputStream encodeToBytes() throws IOException {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(new GZIPOutputStream(buf));
oos.writeObject(this);
oos.close();
ByteArrayOutputStream buf2 = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(new Base64OutputStream(buf2,true,-1,null));
buf2.write(PREAMBLE);
dos.writeInt(buf.size());
buf.writeTo(dos);
dos.close();
buf2.write(POSTAMBLE);
return buf2;
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
private ByteArrayOutputStream encodeToBytes() throws IOException {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(new GZIPOutputStream(buf));
oos.writeObject(this);
oos.close();
ByteArrayOutputStream buf2 = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(new Base64OutputStream(buf2,true,-1,null));
buf2.write(PREAMBLE);
dos.writeInt(buf.size());
buf.writeTo(dos);
dos.close();
buf2.write(POSTAMBLE);
return buf2;
}
代码示例来源:origin: hudson/hudson-2.x
private ByteArrayOutputStream encodeToBytes() throws IOException {
ByteArrayOutputStream buf = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(new GZIPOutputStream(buf));
oos.writeObject(this);
oos.close();
ByteArrayOutputStream buf2 = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(new Base64OutputStream(buf2,true,-1,null));
buf2.write(PREAMBLE);
dos.writeInt(buf.size());
buf.writeTo(dos);
dos.close();
buf2.write(POSTAMBLE);
return buf2;
}
代码示例来源:origin: Nextdoor/bender
protected ByteArrayOutputStream compress(ByteArrayOutputStream raw) throws TransportException {
ByteArrayOutputStream compressed = new ByteArrayOutputStream();
BZip2CompressorOutputStream bcos = null;
try {
bcos = new BZip2CompressorOutputStream(compressed);
} catch (IOException e) {
throw new TransportException("unable to open compressed stream", e);
}
try {
raw.writeTo(bcos);
bcos.flush();
} catch (IOException e) {
throw new TransportException("unable to compress data", e);
} finally {
try {
bcos.close();
} catch (IOException e) {
}
}
return compressed;
}
内容来源于网络,如有侵权,请联系作者删除!