Package org.postgresql.largeobject
Class BlobOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.postgresql.largeobject.BlobOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class BlobOutputStream extends java.io.OutputStream
This implements a basic output stream that writes to a LargeObject.
-
-
Field Summary
Fields Modifier and Type Field Description private int
bpos
Position within the buffer.private int
bsize
Size of the buffer (default 1K).private byte[]
buf
Buffer.private LargeObject
lo
The parent LargeObject.
-
Constructor Summary
Constructors Constructor Description BlobOutputStream(LargeObject lo)
Create an OutputStream to a large object.BlobOutputStream(LargeObject lo, int bsize)
Create an OutputStream to a large object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkClosed()
void
close()
void
flush()
Flushes this output stream and forces any buffered output bytes to be written out.void
write(byte[] buf, int off, int len)
void
write(int b)
-
-
-
Field Detail
-
lo
private LargeObject lo
The parent LargeObject.
-
buf
private byte[] buf
Buffer.
-
bsize
private int bsize
Size of the buffer (default 1K).
-
bpos
private int bpos
Position within the buffer.
-
-
Constructor Detail
-
BlobOutputStream
public BlobOutputStream(LargeObject lo)
Create an OutputStream to a large object.- Parameters:
lo
- LargeObject
-
BlobOutputStream
public BlobOutputStream(LargeObject lo, int bsize)
Create an OutputStream to a large object.- Parameters:
lo
- LargeObjectbsize
- The size of the buffer used to improve performance
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] buf, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
Flushes this output stream and forces any buffered output bytes to be written out. The general contract offlush
is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
- if an I/O error occurs.
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
checkClosed
private void checkClosed() throws java.io.IOException
- Throws:
java.io.IOException
-
-