FileDocCategorySizeDatePackage
UnsynchronizedBufferedWriter.javaAPI DocExample1791Wed Feb 15 05:30:30 GMT 2006com.elharo.io

UnsynchronizedBufferedWriter

public class UnsynchronizedBufferedWriter extends Writer

Fields Summary
private static final int
CAPACITY
private char[]
buffer
private int
position
private Writer
out
private boolean
closed
Constructors Summary
public UnsynchronizedBufferedWriter(Writer out)

  
     
    this.out = out;
  
Methods Summary
private voidcheckClosed()

    if (closed) throw new IOException("Writer is closed"); 
  
public voidclose()

    closed = true;
    this.flush();
    out.close();
  
public voidflush()

    flushInternal();
    out.flush();
  
private voidflushInternal()

    if (position != 0) {
      out.write(buffer, 0, position);
      position = 0;
    }
  
public voidwrite(char[] text, int offset, int length)

    checkClosed();
    while (length > 0) {
      int n = Math.min(CAPACITY - position, length);
      System.arraycopy(text, offset, buffer, position, n);
      position += n;
      offset += n;
      length -= n;
      if (position >= CAPACITY) flushInternal();
    }
  
public voidwrite(java.lang.String s)

     write(s, 0, s.length());
  
public voidwrite(java.lang.String s, int offset, int length)

    checkClosed();
    while (length > 0) {
      int n = Math.min(CAPACITY - position, length);
      s.getChars(offset, offset + n, buffer, position);
      position += n;
      offset += n;
      length -= n;
      if (position >= CAPACITY) flushInternal();
    }   
  
public voidwrite(int c)

    checkClosed();
    if (position >= CAPACITY) flushInternal();
    buffer[position] = (char) c;
    position++;