org.openjena.atlas.io
Class BufferingWriter

java.lang.Object
  extended by java.io.Writer
      extended by org.openjena.atlas.io.BufferingWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public final class BufferingWriter
extends Writer

A buffering writer, send output to a channel (WriteableByteChannel) (and own methods which do not throw checked exceptions). Only supports UTF-8.

The java.io classes have hidden synchronization so in some very critical situations, this can be expensive (such situations are not common). This class generalises the notion of destination via the Sink abstraction (block output based on ByteBuffers).

This class is not thread safe.

See Also:
PeekReader

Nested Class Summary
static class BufferingWriter.SinkBuffer
           
static class BufferingWriter.SinkChannel
           
static class BufferingWriter.SinkOutputStream
           
 
Constructor Summary
BufferingWriter(Sink<ByteBuffer> sink)
          Create a buffering output stream of charcaters to a Sink
BufferingWriter(Sink<ByteBuffer> sink, int size, int blobSize)
          Create a buffering output stream of charcaters to a Sink
 
Method Summary
 void close()
           
static BufferingWriter create(OutputStream out)
          Writer(chars) over OutputStream (bytes) -- heavily buffered -- flushing may be needed
static BufferingWriter create(OutputStream out, int size)
          Convenience operation to output to a Writer
static BufferingWriter create(WritableByteChannel out)
          Convenience operation to output to a WritableByteChannel
static BufferingWriter create(WritableByteChannel out, int size)
          Convenience operation to output to a WritableByteChannel
 void flush()
           
 void output(char[] chars)
          Output an array of characters
 void output(char[] chars, int start, int finish)
          Output an array of characters
 void output(CharSequence string)
          Output characters (The String class implements CharSequence)
 void output(int ch)
          Output a single character
 void write(char[] cbuf)
           
 void write(char[] cbuf, int off, int len)
           
 void write(int ch)
           
 void write(String string)
           
 
Methods inherited from class java.io.Writer
append, append, append, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferingWriter

public BufferingWriter(Sink<ByteBuffer> sink)
Create a buffering output stream of charcaters to a Sink


BufferingWriter

public BufferingWriter(Sink<ByteBuffer> sink,
                       int size,
                       int blobSize)
Create a buffering output stream of charcaters to a Sink

Method Detail

create

public static BufferingWriter create(WritableByteChannel out)
Convenience operation to output to a WritableByteChannel


create

public static BufferingWriter create(WritableByteChannel out,
                                     int size)
Convenience operation to output to a WritableByteChannel


create

public static BufferingWriter create(OutputStream out)
Writer(chars) over OutputStream (bytes) -- heavily buffered -- flushing may be needed


create

public static BufferingWriter create(OutputStream out,
                                     int size)
Convenience operation to output to a Writer


output

public void output(CharSequence string)
Output characters (The String class implements CharSequence)


output

public void output(char[] chars)
Output an array of characters


output

public void output(char[] chars,
                   int start,
                   int finish)
Output an array of characters

Parameters:
chars - Characters
start - Start (inclusive)
finish - Finish (exclusive)

output

public void output(int ch)
Output a single character


close

public void close()
Specified by:
close in interface Closeable
Specified by:
close in class Writer

flush

public void flush()
Specified by:
flush in interface Flushable
Specified by:
flush in class Writer

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws IOException
Specified by:
write in class Writer
Throws:
IOException

write

public void write(char[] cbuf)
           throws IOException
Overrides:
write in class Writer
Throws:
IOException

write

public void write(String string)
           throws IOException
Overrides:
write in class Writer
Throws:
IOException

write

public void write(int ch)
           throws IOException
Overrides:
write in class Writer
Throws:
IOException


Licenced under the Apache License, Version 2.0