Package org.basex.io.in
Class BufferInput
java.lang.Object
java.io.InputStream
org.basex.io.in.BufferInput
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
ArrayInput,DataInput,TextInput
This class uses an internal buffer to speed up input stream processing.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor.BufferInput(InputStream in, int bufsize) Initializes the file reader.BufferInput(IO input) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()byte[]content()Retrieves and returns the whole data and closes the stream.static BufferInputget(InputStream in) Returns a buffered input stream.static BufferInputReturns a buffered input stream.final IOio()Returns the IO reference ornull.final longlength()Returns the input length (can be-1).final voidmark(int m) final booleanintread()Returns the next byte.final byte[]Reads a byte array from the input stream, suffixed by a0byte.final StringReads a string from the input stream, suffixed by a0byte.final voidreset()final intsize()Returns the number of read bytes.Methods inherited from class java.io.InputStream
available, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skip, skipNBytes, transferTo
-
Constructor Details
-
BufferInput
Constructor.- Parameters:
input- input to be read- Throws:
IOException- I/O Exception
-
BufferInput
Constructor.- Parameters:
is- input stream
-
BufferInput
Initializes the file reader.- Parameters:
in- input streambufsize- buffer size
-
-
Method Details
-
get
Returns a buffered input stream.- Parameters:
in- input stream- Returns:
- stream
-
get
Returns a buffered input stream.- Parameters:
input- input to be read- Returns:
- stream
- Throws:
IOException- I/O Exception
-
io
Returns the IO reference ornull.- Returns:
- file reference
-
read
Returns the next byte. By default, this method callsreadByte();-1is returned if all bytes have been read.- Specified by:
readin classInputStream- Returns:
- next byte
- Throws:
IOException- I/O exception
-
readString
Reads a string from the input stream, suffixed by a0byte.- Returns:
- string
- Throws:
IOException- I/O Exception
-
readBytes
Reads a byte array from the input stream, suffixed by a0byte.- Returns:
- token
- Throws:
IOException- I/O Exception
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
size
public final int size()Returns the number of read bytes.- Returns:
- read bytes
-
length
public final long length()Returns the input length (can be-1).- Returns:
- input length
-
markSupported
public final boolean markSupported()- Overrides:
markSupportedin classInputStream
-
mark
public final void mark(int m) - Overrides:
markin classInputStream
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
content
Retrieves and returns the whole data and closes the stream.- Returns:
- contents
- Throws:
IOException- I/O exception
-