Package wt.util
Class TempFileOutputStream
java.lang.Object
java.io.OutputStream
wt.util.TempFileOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
This class is designed to be used much like a
ByteArrayOutputStream,
the primary difference being that output is written to a temporary file
as oppose to consuming memory with a byte array.
Note: The dispose method should be called to delete the temporary file and free all
related resources when no longer needed.
Supported API: true
Extendable: false
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a newTempFileOutputStreamobject.TempFileOutputStream(int buffer_size) Construct a newTempFileOutputStreamobject specifying the write buffer size. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Dispose of resources associated with thisTempFileOutputStream.intGet the size of the temporary file.static voidTest driver (main)
Supported API: trueintsize()Get the size of the temporary file.voidwrite(byte[] b) Writesb.lengthbytes to thisTempFileOutputStream.voidwrite(byte[] b, int off, int len) Write data to thisTempFileOutputStream.voidwrite(int b) Write data to thisTempFileOutputStream.voidwriteTo(OutputStream os) Write temp file data to some OutputStream.Methods inherited from class java.io.OutputStream
close, flush, nullOutputStream
-
Constructor Details
-
TempFileOutputStream
Construct a newTempFileOutputStreamobject.
Supported API: true- Throws:
IOException- If unable to open the temporary file.
-
TempFileOutputStream
Construct a newTempFileOutputStreamobject specifying the write buffer size.
Supported API: true- Parameters:
buffer_size-- Throws:
IOException- If unable to open the temporary file.
-
-
Method Details
-
size
public int size()Get the size of the temporary file.
Supported API: true- Returns:
- the size of the temporary file
-
getLength
public int getLength()Get the size of the temporary file.
Supported API: true- Returns:
- the size of the temporary file
-
write
Write data to thisTempFileOutputStream.
Supported API: true- Overrides:
writein classOutputStream- Parameters:
b- a byte array of data to be written to temporary fileoff- offset into the byte arraylen- amout of data to be written- Throws:
IOException- if a write error occurs.
-
write
Write data to thisTempFileOutputStream.
Supported API: true- Specified by:
writein classOutputStream- Parameters:
b- a byte array of data to be written to temporary fileoff- offset into the byte arraylen- amout of data to be written- Throws:
IOException- if a write error occurs.
-
write
Writesb.lengthbytes to thisTempFileOutputStream.
Supported API: true- Overrides:
writein classOutputStream- Parameters:
b- a byte array of data to be written to temporary file- Throws:
IOException- if a write error occurs.
-
writeTo
Write temp file data to some OutputStream.
Supported API: true- Parameters:
os- OutputStream which is to recievie the temp files contents- Throws:
IOException- if a read or write error errors.
-
dispose
public void dispose()Dispose of resources associated with thisTempFileOutputStream. The temporary file is closed and deleted.
Supported API: true -
main
Test driver (main)
Supported API: true
-