Package com.clickhouse.client.stream
Class EmptyInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.clickhouse.client.ClickHouseInputStream
-
- com.clickhouse.client.stream.EmptyInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class EmptyInputStream extends ClickHouseInputStream
Empty input stream produces nothing and it can never be closed.
-
-
Field Summary
Fields Modifier and Type Field Description static EmptyInputStreamINSTANCE-
Fields inherited from class com.clickhouse.client.ClickHouseInputStream
byteBuffer, closed, copyTo, EMPTY_BUFFER, EMPTY_BYTES, ERROR_INCOMPLETE_READ, ERROR_NULL_BYTES, ERROR_REUSE_BUFFER, ERROR_STREAM_CLOSED, file, postCloseAction
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()booleanisClosed()Checks if the input stream has been closed or not.intpeek()Peeks one byte.longpipe(ClickHouseOutputStream output)Reads all remaining bytes and write into given output stream.intread()bytereadByte()Reads one single byte from the input stream.ClickHouseByteBufferreadCustom(ClickHouseDataUpdater reader)Reads bytes using custom reader.longskip(long n)-
Methods inherited from class com.clickhouse.client.ClickHouseInputStream
closeQuietly, empty, ensureOpen, getUnderlyingFile, of, of, of, of, of, of, of, of, of, of, of, of, of, of, of, of, pipe, pipe, readAsciiString, readAsciiString, readBuffer, readBytes, readString, readString, readUnicodeString, readUnicodeString, readUnsignedByte, readVarInt, readVarLong, save, save, setCopyToTarget, wrap
-
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, transferTo
-
-
-
-
Field Detail
-
INSTANCE
public static final EmptyInputStream INSTANCE
-
-
Method Detail
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classClickHouseInputStream- Throws:
IOException
-
peek
public int peek() throws IOExceptionDescription copied from class:ClickHouseInputStreamPeeks one byte. It's similar asInputStream.read()except it never changes cursor.- Specified by:
peekin classClickHouseInputStream- Returns:
- the next byte of data, or -1 if the end of the stream is reached
- Throws:
IOException- when failed to read value from input stream or reached end of the stream
-
pipe
public long pipe(ClickHouseOutputStream output) throws IOException
Description copied from class:ClickHouseInputStreamReads all remaining bytes and write into given output stream. Current input stream will be closed automatically at the end of writing, butoutputwill remain open.- Specified by:
pipein classClickHouseInputStream- Parameters:
output- non-null output stream- Returns:
- bytes being written into output stream
- Throws:
IOException- when failed to read value from input stream or reached end of the stream
-
readByte
public byte readByte() throws IOExceptionDescription copied from class:ClickHouseInputStreamReads one single byte from the input stream. UnlikeInputStream.read(), it will throwIOExceptionif the input stream has been closed. In general, this method should be faster thanInputStream.read(), especially when it's an input stream backed by byte[] orByteBuffer.- Specified by:
readBytein classClickHouseInputStream- Returns:
- byte value if present
- Throws:
IOException- when failed to read value from input stream or reached end of the stream
-
readCustom
public ClickHouseByteBuffer readCustom(ClickHouseDataUpdater reader) throws IOException
Description copied from class:ClickHouseInputStreamReads bytes using custom reader. Stream will be closed automatically when it reached end of stream. However, unlikeClickHouseInputStream.readBuffer(int), this method will never throwEOFException.- Specified by:
readCustomin classClickHouseInputStream- Parameters:
reader- non-null data reader- Returns:
- non-null byte buffer
- Throws:
IOException- when failed to read bytes from input stream, not able to retrieve all bytes, or reached end of the stream
-
read
public int read() throws IOException- Specified by:
readin classInputStream- Throws:
IOException
-
isClosed
public boolean isClosed()
Description copied from class:ClickHouseInputStreamChecks if the input stream has been closed or not.- Overrides:
isClosedin classClickHouseInputStream- Returns:
- true if the input stream has been closed; false otherwise
-
available
public int available() throws IOException- Overrides:
availablein classInputStream- Throws:
IOException
-
skip
public long skip(long n) throws IOException- Overrides:
skipin classInputStream- Throws:
IOException
-
-