Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2004-2010 Oracle Corporation. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: Kohsuke Kawaguchi /
 
package org.kohsuke.stapler.framework.io;
java.io.Writer that spools the output and writes to another java.io.Writer later.

Author(s):
Kohsuke Kawaguchi
public /*for now, until Hudson migration completes*/ final class CharSpool extends Writer {
    private List<char[]> buf;
    private char[] last = new char[1024];
    private int pos;
    public void write(char cbuf[], int offint len) {
        while(len>0) {
            int sz = Math.min(.-,len);
            System.arraycopy(cbuf,off,,,sz);
            len -= sz;
            off += sz;
             += sz;
            renew();
        }
    }
    private void renew() {
        if(<.)
            return;
        if(==null)
             = new LinkedList<char[]>();
        .add();
         = new char[1024];
         = 0;
    }
    public void write(int c) {
        renew();
        [++] = (char)c;
    }
    public void flush() {
        // noop
    }
    public void close() {
        // noop
    }
    public void writeTo(Writer wthrows IOException {
        if(!=null) {
            for (char[] cb : ) {
                w.write(cb);
            }
        }
        w.write(,0,);
    }
New to GrepCode? Check out our FAQ X