|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
org.eclipse.jgit.util.TemporaryBuffer
public class TemporaryBuffer
A fully buffered output stream using local disk storage for large data.
Initially this output stream buffers to memory, like ByteArrayOutputStream might do, but it shifts to using an on disk temporary file if the output gets too large.
The content of this buffered stream may be sent to another OutputStream only
after this stream has been properly closed by close().
| Constructor Summary | |
|---|---|
TemporaryBuffer()
Create a new empty temporary buffer. |
|
| Method Summary | |
|---|---|
void |
close()
|
void |
copy(java.io.InputStream in)
Copy all bytes remaining on the input stream into this buffer. |
void |
destroy()
Clear this buffer so it has no data, and cannot be used again. |
long |
length()
Obtain the length (in bytes) of the buffer. |
byte[] |
toByteArray()
Convert this buffer's contents into a contiguous byte array. |
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
void |
writeTo(java.io.OutputStream os,
ProgressMonitor pm)
Send this buffer to an output stream. |
| Methods inherited from class java.io.OutputStream |
|---|
flush, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TemporaryBuffer()
| Method Detail |
|---|
public void write(int b)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOException
public void write(byte[] b,
int off,
int len)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOException
public void copy(java.io.InputStream in)
throws java.io.IOException
in - the stream to read from, until EOF is reached.
java.io.IOException - an error occurred reading from the input stream, or while
writing to a local temporary file.
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.OutputStreamjava.io.IOExceptionpublic long length()
The length is only accurate after close() has been invoked.
public byte[] toByteArray()
throws java.io.IOException
The buffer is only complete after close() has been invoked.
length().
java.io.IOException - an error occurred reading from a local temporary file
java.lang.OutOfMemoryError - the buffer cannot fit in memory
public void writeTo(java.io.OutputStream os,
ProgressMonitor pm)
throws java.io.IOException
This method may only be invoked after close() has completed
normally, to ensure all data is completely transferred.
os - stream to send this buffer's complete content to.pm - if not null progress updates are sent here. Caller should
initialize the task and the number of work units to
length()/1024.
java.io.IOException - an error occurred reading from a temporary file on the local
system, or writing to the output stream.public void destroy()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||