Package org.elasticsearch.common.io
Class UTF8StreamWriter
org.elasticsearch.common.io.UTF8StreamWriter
- All Implemented Interfaces:
,
,
,
public final class UTF8StreamWriter
extends
-
Field Summary
Fields inherited from class java.io.
-
Constructor Summary
ConstructorDescriptionCreates a UTF-8 writer having a byte buffer of moderate capacity (2048).UTF8StreamWriter(int capacity)
Creates a UTF-8 writer having a byte buffer of specified capacity. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes andresets
this writer for reuse.void
flush()
Flushes the stream.void
reset()
out)
Sets the output stream to use for writing until this writer is closed.void
write(char c)
Writes a single character.void
write(char[] cbuf, int off, int len)
Writes a portion of an array of characters.void
write(int code)
Writes a character given its 31-bits Unicode.void
csq)
Writes the specified character sequence.void
str, int off, int len)
Writes a portion of a string.Methods inherited from class java.io.
, , , , ,
Methods inherited from class java.lang.
, , , , , , , , , ,
-
Constructor Details
-
UTF8StreamWriter
public UTF8StreamWriter()Creates a UTF-8 writer having a byte buffer of moderate capacity (2048). -
UTF8StreamWriter
public UTF8StreamWriter(int capacity)Creates a UTF-8 writer having a byte buffer of specified capacity.- Parameters:
capacity
- the capacity of the byte buffer.
-
-
Method Details
-
setOutput
public out)Sets the output stream to use for writing until this writer is closed. For example:[code] Writer writer = new UTF8StreamWriter().setOutputStream(out); [/code] is equivalent but writes faster than [code] Writer writer = new java.io.OutputStreamWriter(out, "UTF-8"); [/code] -
write
public void write(char c) throwsWrites a single character. This method supports 16-bits character surrogates.- Parameters:
c
-char
the character to be written (possibly a surrogate).- Throws:
- if an I/O error occurs.
-
write
public void write(int code) throwsWrites a character given its 31-bits Unicode.- Overrides:
in class
- Parameters:
code
- the 31 bits Unicode of the character to be written.- Throws:
- if an I/O error occurs.
-
write
public void write(char[] cbuf, int off, int len) throwsWrites a portion of an array of characters.- Specified by:
in class
- Parameters:
cbuf
- the array of characters.off
- the offset from which to start writing characters.len
- the number of characters to write.- Throws:
- if an I/O error occurs.
-
write
public void write( str, int off, int len) throwsWrites a portion of a string.- Overrides:
in class
- Parameters:
str
- a String.off
- the offset from which to start writing characters.len
- the number of characters to write.- Throws:
- if an I/O error occurs
-
write
public void write( csq) throwsWrites the specified character sequence.- Parameters:
csq
- the character sequence.- Throws:
- if an I/O error occurs
-
flush
public void flush() throwsFlushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.- Specified by:
in interface
- Specified by:
in class
- Throws:
- if an I/O error occurs.
-
close
public void close() throwsCloses andresets
this writer for reuse.- Specified by:
in interface
- Specified by:
in interface
- Specified by:
in class
- Throws:
- if an I/O error occurs
-
reset
public void reset()
-