|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.OutputStream | +--com.caucho.vfs.WriteStream
A fast bufferered output stream supporting both character and byte data. The underlying stream sources are provided by StreamImpl classes, so all streams have the same API regardless of the underlying implementation.
OutputStream and Writers are combined. The write
routines
write bytes and the print
routines write characters.
Most applications will use the Path routines to create their own streams. Specialized applications, like servers, need the capability of recycling streams.
Constructor Summary | |
WriteStream()
Creates an uninitialized stream. |
|
WriteStream(StreamImpl source)
Creates a stream and initializes with a specified source. |
Method Summary | |
boolean |
canWrite()
Returns true if the buffer allows writes. |
void |
clearWrite()
Clears the write buffer |
void |
close()
Close the stream, first flushing the write buffer. |
void |
flush()
Flushes the buffer to the source. |
java.lang.Object |
getAttribute(java.lang.String name)
Returns a named attribute. |
java.util.Iterator |
getAttributeNames()
Lists all named attributes. |
byte[] |
getBuffer()
Returns the write buffer. |
int |
getBufferOffset()
Returns the write offset. |
java.lang.String |
getEncoding()
Returns the mime-encoding used for writing. |
java.lang.String |
getJavaEncoding()
|
java.lang.String |
getNewlineString()
Returns the current string used for println newlines |
Path |
getPath()
Returns the Path which opened this stream. |
java.io.PrintWriter |
getPrintWriter()
Returns a printWriter writing to this stream. |
int |
getRemaining()
Returns the bytes remaining in the buffer. |
StreamImpl |
getSource()
Returns the underlying source for the stream. |
java.lang.String |
getUserPath()
Returns the user path which opened this stream. |
void |
init(StreamImpl source)
Initializes the stream with a given source. |
void |
log(java.lang.String string)
Logs a line to the stream. |
void |
log(java.lang.Throwable exn)
|
void |
print(boolean b)
Prints a boolean. |
void |
print(char ch)
Prints the character buffer to the stream. |
void |
print(char[] buffer)
Prints the character buffer to the stream. |
void |
print(char[] buffer,
int offset,
int length)
Prints the character buffer to the stream. |
void |
print(double d)
Prints an double |
void |
print(float f)
Prints a float. |
void |
print(int i)
Prints an integer. |
void |
print(long i)
Prints a long. |
void |
print(java.lang.Object o)
Prints a double, converted by String.valueOf() |
void |
print(java.lang.String string)
Prints a string. |
void |
print(java.lang.String string,
int off,
int len)
Prints a substring. |
void |
println()
Prints a newline |
void |
println(boolean b)
Prints a boolean followed by a newline. |
void |
println(char ch)
Prints a char followed by a newline. |
void |
println(char[] buf,
int offset,
int length)
Prints a character buffer followed by a newline. |
void |
println(double d)
Prints a double followed by a newline. |
void |
println(float f)
Prints a float followed by a newline. |
void |
println(int i)
Prints an integer followed by a newline. |
void |
println(long l)
Prints a long followed by a newline. |
void |
println(java.lang.Object o)
Prints an object, converted to a string, followed by a newline. |
void |
println(java.lang.String string)
Prints a string buffer followed by a newline. |
void |
pushFilter(StreamFilter filter)
Pushes a filter on the top of the stream stack. |
void |
removeAttribute(java.lang.String name)
Removes a named attribute. |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets a named attribute. |
void |
setBufferOffset(int offset)
Sets the write offset. |
void |
setDisableClose(boolean disableClose)
Disables close. |
void |
setEncoding(java.lang.String encoding)
Sets the character encoding for writing to this stream. |
void |
setFlushOnNewline(boolean flushOnNewline)
Some streams, like log streams, should be flushed on every println call. |
void |
setLocale(java.util.Locale locale)
|
void |
setNewlineString(java.lang.String newline)
Sets the string to use for println newlines |
void |
setPath(Path path)
Sets a path name associated with the stream. |
void |
setReuseBuffer(boolean reuse)
|
void |
setWritePrefix(int prefix)
|
void |
write(byte[] buf)
Writes a byte array. |
void |
write(byte[] buf,
int offset,
int length)
Writes a byte array |
void |
write(int ch)
Writes a byte. |
void |
writeFile(Path path)
Copies a file to the stream. |
void |
writeStream(java.io.InputStream source)
Writes the contents of a JDK stream. |
void |
writeStream(java.io.InputStream source,
int totalLength)
Writes the contents of a JDK stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WriteStream()
init
to initialize.public WriteStream(StreamImpl source)
source
- Underlying source for the stream.Method Detail |
public void init(StreamImpl source)
source
- Underlying source for the stream.public StreamImpl getSource()
public void pushFilter(StreamFilter filter)
filter
- the filter to be added.public boolean canWrite()
LogStreams, used for debugging, use this feature to
test if they should write with very little overhead.
if (dbg.canWrite())
dbg.log("some debug value " + expensiveDebugCalculation(foo));
public void clearWrite()
public void setWritePrefix(int prefix)
public void setReuseBuffer(boolean reuse)
public byte[] getBuffer()
public int getBufferOffset()
public void setBufferOffset(int offset)
public int getRemaining()
public void write(int ch) throws java.io.IOException
write
in class java.io.OutputStream
public void write(byte[] buf, int offset, int length) throws java.io.IOException
write
in class java.io.OutputStream
public void write(byte[] buf) throws java.io.IOException
write
in class java.io.OutputStream
public void flush() throws java.io.IOException
flush
in class java.io.OutputStream
public void setEncoding(java.lang.String encoding) throws java.io.UnsupportedEncodingException
public void setLocale(java.util.Locale locale) throws java.io.UnsupportedEncodingException
public java.lang.String getEncoding()
public java.lang.String getJavaEncoding()
public void setFlushOnNewline(boolean flushOnNewline)
flushOnNewline
- set to true if println flushes.public java.lang.String getNewlineString()
public void setNewlineString(java.lang.String newline)
public final void print(char[] buffer, int offset, int length) throws java.io.IOException
buffer
- character buffer to writeoffset
- offset into the buffer to start writeslength
- number of characters to writepublic final void print(char ch) throws java.io.IOException
ch
- charpublic final void print(char[] buffer) throws java.io.IOException
buffer
- character buffer to writepublic final void print(java.lang.String string) throws java.io.IOException
public final void print(java.lang.String string, int off, int len) throws java.io.IOException
public final void print(boolean b) throws java.io.IOException
public final void print(int i) throws java.io.IOException
public final void print(long i) throws java.io.IOException
public final void print(float f) throws java.io.IOException
public final void print(double d) throws java.io.IOException
public final void print(java.lang.Object o) throws java.io.IOException
public final void println() throws java.io.IOException
public final void println(char[] buf, int offset, int length) throws java.io.IOException
public final void println(java.lang.String string) throws java.io.IOException
public final void println(boolean b) throws java.io.IOException
public final void println(char ch) throws java.io.IOException
public final void println(int i) throws java.io.IOException
public final void println(long l) throws java.io.IOException
public final void println(float f) throws java.io.IOException
public final void println(double d) throws java.io.IOException
public final void println(java.lang.Object o) throws java.io.IOException
public java.io.PrintWriter getPrintWriter()
public final void log(java.lang.String string)
public final void log(java.lang.Throwable exn)
public void writeStream(java.io.InputStream source) throws java.io.IOException
source
to the current stream.source
- InputStream to read.public void writeStream(java.io.InputStream source, int totalLength) throws java.io.IOException
source
to the current stream.source
- InputStream to read.public void writeFile(Path path) throws java.io.IOException
path
- Path of the file to copy.public void setDisableClose(boolean disableClose)
public final void close() throws java.io.IOException
close
in class java.io.OutputStream
public java.lang.Object getAttribute(java.lang.String name) throws java.io.IOException
public void setAttribute(java.lang.String name, java.lang.Object value) throws java.io.IOException
public void removeAttribute(java.lang.String name) throws java.io.IOException
public java.util.Iterator getAttributeNames() throws java.io.IOException
public Path getPath()
public java.lang.String getUserPath()
Parsing routines typically use this for error reporting.
public void setPath(Path path)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |