java.io

Class CharArrayWriter

Implemented Interfaces:
Appendable, Closeable, Flushable

public class CharArrayWriter
extends Writer

This class implements a character buffer that can be used as an Writer. The buffer automatically grows when data is written to the stream. The data can be retrieved using toCharArray() and toString().

Note: Invoking close() on this class has no effect, and methods of this class can be called after the stream has closed without generating an IOException.

Since:
JDK1.1

Field Summary

protected char[]
buf
The buffer where data is stored.
protected int
count
The number of chars in the buffer.

Fields inherited from class java.io.Writer

lock

Constructor Summary

CharArrayWriter()
Creates a new CharArrayWriter.
CharArrayWriter(int initialSize)
Creates a new CharArrayWriter with the specified initial size.

Method Summary

CharArrayWriter
append(char c)
Appends the specified character to this writer.
CharArrayWriter
append(CharSequence csq)
Appends the specified character sequence to this writer.
CharArrayWriter
append(CharSequence csq, int start, int end)
Appends a subsequence of the specified character sequence to this writer.
void
close()
Close the stream.
void
flush()
Flush the stream.
void
reset()
Resets the buffer so that you can use it again without throwing away the already allocated buffer.
int
size()
Returns the current size of the buffer.
char[]
toCharArray()
Returns a copy of the input data.
String
toString()
Converts input data to a string.
void
write(c[] , int off, int len)
Writes characters to the buffer.
void
write(int c)
Writes a character to the buffer.
void
write(String str, int off, int len)
Write a portion of a string to the buffer.
void
writeTo(Writer out)
Writes the contents of the buffer to another character stream.

Methods inherited from class java.io.Writer

append, append, append, close, flush, write, write, write, write, write

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

buf

protected char[] buf
The buffer where data is stored.

count

protected int count
The number of chars in the buffer.

Constructor Details

CharArrayWriter

public CharArrayWriter()
Creates a new CharArrayWriter.
Usages and Demos :

View More Examples of CharArrayWriter()
   1:       System.err.print("Enter password: ");
   2:       CharArrayWriter writer = new CharArrayWriter();
   3:       int b;
   4:       while( (b = System.in.read()) >= 0 )
   5:       {

View Full Code Here
   1:     super(rs);
   2:     antwort = new CharArrayWriter();
   3:   }
   4:   public PrintWriter getWriter() {
   5:     return new PrintWriter(antwort);

View Full Code Here
   1: 
   2:             CharArrayWriter writer = new CharArrayWriter();
   3:             PDFTextStripper stripper = new PDFTextStripper();
   4:             stripper.writeText(pdfDocument, writer);

View Full Code Here
   1: {
   2:     private CharArrayWriter text = new CharArrayWriter();
   3:     private DMetalink dMetalink;
   4:     Attributes atr;
   5:     

View Full Code Here
   1:         super(response);
   2:         output = new CharArrayWriter();
   3:     }
   4:     
   5:     public PrintWriter getWriter() 

View Full Code Here

CharArrayWriter

public CharArrayWriter(int initialSize)
Creates a new CharArrayWriter with the specified initial size.
Parameters:
initialSize - an int specifying the initial buffer size.
Throws:
IllegalArgumentException - if initialSize is negative
Usages and Demos :

View More Examples of CharArrayWriter(int initialSize)
   1:     private String eventToString(XmlObject xmlObject) throws RepositoryException {
   2:         CharArrayWriter writer = new CharArrayWriter(5000);
   3:         try {
   4:             xmlObject.save(writer);
   5:         } catch (IOException e) {

View Full Code Here
   1: 
   2:       CharArrayWriter caw = new CharArrayWriter(24);
   3:       BufferedWriter bw = new BufferedWriter(caw, 12);
   4: 
   5:       String str = "I used to live right behind this super-cool bar in\n" +

View Full Code Here
   1:     {
   2:         CharArrayWriter out = new CharArrayWriter(4096);
   3:         transfer(reader, out);
   4:         out.close();

View Full Code Here
   1:             }
   2:             this.writer = new CharArrayWriter(5000);
   3:             serializer.setResult(new StreamResult(writer));
   4:             this.serializer.startDocument();
   5:         } else if (inSerialize) {

View Full Code Here
   1:             super(r);
   2:             output = new CharArrayWriter( INIT_BUFFER_SIZE );
   3:         }
   4: 
   5:         public PrintWriter getWriter()

View Full Code Here

Method Details

append

public CharArrayWriter append(char c)
Appends the specified character to this writer.

An invocation of this method of the form out.append(c) behaves in exactly the same way as the invocation

     out.write(c) 
Specified by:
append in interface Appendable
Overrides:
append in interface Writer
Parameters:
c - The 16-bit character to append
Returns:
This writer
Since:
1.5
Usages and Demos :

View More Examples of append(char c)
   1: import java.io.PrintWriter;
   2: import java.io.CharArrayWriter;
   3: import java.text.NumberFormat;
   4:         ...
   5:                 description : resources.getString(ResourceKeys.PROGRESSION));
   6:         buffer.append(": "); format.format(percent/100, buffer, new FieldPosition(0));
   7:         ...
   8:         buffer.append('\n');
   9:         buffer.append(resources.getString(ResourceKeys.MEMORY_HEAP_SIZE_$1,
  10:         ...
  11:                                           new Float(totalMemory)));
  12:         buffer.append('\n');

View Full Code Here
   1:         StringBuffer buffer = new StringBuffer( 40 + msgText.length() );
   2:         buffer.append( getTimeString() );
   3:         ...
   4:         buffer.append( " ");
   5:         ...
   6:         buffer.append( getLogLevelName( aVerboseLevel ) );
   7:         buffer.append( "/" );
   8:         ...
   9:     {
  10:         CharArrayWriter buffer = new CharArrayWriter();

View Full Code Here
   1: 
   2: import java.io.CharArrayWriter;
   3: import java.io.File;
   4:         ...
   5:     if (fIdentity.get() != null) {
   6:       toReturn.append("(" + (String) fIdentity.get() + ") ");
   7:     }
   8:         ...
   9:       } else {
  10:         toReturn = toReturn.append(currentLine);
  11:         stack = stack.substring(stack.indexOf('\n') + 1, stack.length());
  12:         ...
  13:   private static String getStackTrace(Throwable throwable) {
  14:     CharArrayWriter toReturn = new CharArrayWriter();

View Full Code Here

append

public CharArrayWriter append(CharSequence csq)
Appends the specified character sequence to this writer.

An invocation of this method of the form out.append(csq) behaves in exactly the same way as the invocation

     out.write(csq.toString()) 

Depending on the specification of toString for the character sequence csq, the entire sequence may not be appended. For instance, invoking the toString method of a character buffer will return a subsequence whose content depends upon the buffer's position and limit.

Specified by:
append in interface Appendable
Overrides:
append in interface Writer
Parameters:
csq - The character sequence to append. If csq is null, then the four characters "null" are appended to this writer.
Returns:
This writer
Since:
1.5
Usages and Demos :

View More Examples of append(CharSequence csq)
   1: import java.io.PrintWriter;
   2: import java.io.CharArrayWriter;
   3: import java.text.NumberFormat;
   4:         ...
   5:                 description : resources.getString(ResourceKeys.PROGRESSION));
   6:         buffer.append(": "); format.format(percent/100, buffer, new FieldPosition(0));
   7:         ...
   8:         buffer.append('\n');
   9:         buffer.append(resources.getString(ResourceKeys.MEMORY_HEAP_SIZE_$1,
  10:         ...
  11:                                           new Float(totalMemory)));
  12:         buffer.append('\n');

View Full Code Here
   1:         StringBuffer buffer = new StringBuffer( 40 + msgText.length() );
   2:         buffer.append( getTimeString() );
   3:         ...
   4:         buffer.append( " ");
   5:         ...
   6:         buffer.append( getLogLevelName( aVerboseLevel ) );
   7:         buffer.append( "/" );
   8:         ...
   9:     {
  10:         CharArrayWriter buffer = new CharArrayWriter();

View Full Code Here
   1: 
   2: import java.io.CharArrayWriter;
   3: import java.io.File;
   4:         ...
   5:     if (fIdentity.get() != null) {
   6:       toReturn.append("(" + (String) fIdentity.get() + ") ");
   7:     }
   8:         ...
   9:       } else {
  10:         toReturn = toReturn.append(currentLine);
  11:         stack = stack.substring(stack.indexOf('\n') + 1, stack.length());
  12:         ...
  13:   private static String getStackTrace(Throwable throwable) {
  14:     CharArrayWriter toReturn = new CharArrayWriter();

View Full Code Here

append

public CharArrayWriter append(CharSequence csq,
                              int start,
                              int end)
Appends a subsequence of the specified character sequence to this writer.

An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation

     out.write(csq.subSequence(start, end).toString()) 
Specified by:
append in interface Appendable
Overrides:
append in interface Writer
Parameters:
csq - The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".
start - The index of the first character in the subsequence
end - The index of the character following the last character in the subsequence
Returns:
This writer
Throws:
IndexOutOfBoundsException - If start or end are negative, start is greater than end, or end is greater than csq.length()
Since:
1.5

close

public void close()
Close the stream. This method does not release the buffer, since its contents might still be required. Note: Invoking this method in this class will have no effect.
Specified by:
close in interface Closeable
Overrides:
close in interface Writer
Usages and Demos :

View More Examples of close()
   1:     
   2:   static CharArrayWriter outputBuffer;
   3:   static Writer[] writers;
   4:         ...
   5:   
   6:     public static CharArrayWriter getOutputBuffer() {
   7:     return outputBuffer;
   8:         ...
   9:             
  10:             outputBuffer  = new CharArrayWriter();
  11:       int tablength = granule.getTableTagLength();
  12:         ...
  13:                 
  14:       inlst.close();

View Full Code Here
   1:     
   2:   static CharArrayWriter outputBuffer;
   3:   static Writer[] writers;
   4:         ...
   5:   
   6:     public static CharArrayWriter getOutputBuffer() {
   7:     return outputBuffer;
   8:         ...
   9:             
  10:             outputBuffer  = new CharArrayWriter();
  11:       int tablength = collection.getTableTagLength();
  12:         ...
  13:                 
  14:       inlst.close();

View Full Code Here
   1: 
   2: public class CharArrayWriterUpperCase extends CharArrayWriter {
   3: 
   4:         ...
   5: 
   6:     CharArrayWriter writer = new CharArrayWriter();
   7: 
   8:         ...
   9:     public void close() {
  10:         writer.close();
  11:     }

View Full Code Here
   1: 
   2:     private CharArrayWriter mMessageBuffer;
   3:     private Thread mMessageThread;
   4:         ...
   5: 
   6:         mMessageBuffer = new CharArrayWriter();
   7:     }
   8:         ...
   9: 
  10:         mMessageBuffer = new CharArrayWriter();
  11:     }
  12:         ...
  13:         synchronized (lock) {
  14:             mMessageBuffer.close();

View Full Code Here
   1:     private ByteArrayOutputStream bos = null;
   2:     private CharArrayWriter  caw = null;
   3:     private SAXParser parser = null;
   4:         ...
   5:             transformedDoc = null;
   6:             caw = new CharArrayWriter(); 
   7:             Reader reader = in.getCharacterStream();
   8:         ...
   9:             caw = new CharArrayWriter();
  10:             long total =0;
  11:         ...
  12:             }
  13:             caw.close();

View Full Code Here

flush

public void flush()
Flush the stream.
Specified by:
flush in interface Flushable
Overrides:
flush in interface Writer
Usages and Demos :

View More Examples of flush()
   1:     
   2:   static CharArrayWriter outputBuffer;
   3:   static Writer[] writers;
   4:         ...
   5:   
   6:     public static CharArrayWriter getOutputBuffer() {
   7:     return outputBuffer;
   8:         ...
   9:             
  10:             outputBuffer  = new CharArrayWriter();
  11:       int tablength = granule.getTableTagLength();
  12:         ...
  13:       inlst.close();
  14:       outputBuffer.flush();

View Full Code Here
   1:     
   2:   static CharArrayWriter outputBuffer;
   3:   static Writer[] writers;
   4:         ...
   5:   
   6:     public static CharArrayWriter getOutputBuffer() {
   7:     return outputBuffer;
   8:         ...
   9:             
  10:             outputBuffer  = new CharArrayWriter();
  11:       int tablength = collection.getTableTagLength();
  12:         ...
  13:       inlst.close();
  14:       outputBuffer.flush();

View Full Code Here
   1: 
   2: public class CharArrayWriterUpperCase extends CharArrayWriter {
   3: 
   4:         ...
   5: 
   6:     CharArrayWriter writer = new CharArrayWriter();
   7: 
   8:         ...
   9:     public void flush() {
  10:         writer.flush();
  11:     }

View Full Code Here
   1: import java.io.CharArrayReader;
   2: import java.io.CharArrayWriter;
   3: import java.io.InputStream;
   4:         ...
   5:       
   6:       out.flush();
   7:       Reader in = getResultReader();
   8:         ...
   9:       {
  10:         CharArrayWriter out = new CharArrayWriter(Character.MAX_VALUE);
  11:         final int maxChar = this.charset.name().startsWith("UTF-") 

View Full Code Here
   1: import java.awt.print.PrinterJob;
   2: import java.io.CharArrayWriter;
   3: import java.io.File;
   4:         ...
   5: 
   6:             CharArrayWriter out = new CharArrayWriter();
   7: 
   8:         ...
   9:             dft.processTemplate(temp, star, out);
  10:             out.flush();
  11: 
  12:         ...
  13:                 dft.processTemplate(temp, planet, this.star, out);
  14:                 out.flush();

View Full Code Here

reset

public void reset()
Resets the buffer so that you can use it again without throwing away the already allocated buffer.
Usages and Demos :

View More Examples of reset()
   1: import java.io.IOException;
   2: import java.io.CharArrayWriter;
   3: 
   4:         ...
   5:       System.err.print("Enter password: ");
   6:       CharArrayWriter writer = new CharArrayWriter();
   7:       int b;
   8:         ...
   9:       char[] password = writer.toCharArray();
  10:       writer.reset();
  11:       for(int n = 0; n < password.length; n ++)

View Full Code Here
   1: 
   2: import java.io.CharArrayWriter;
   3: 
   4:         ...
   5: {
   6:     private CharArrayWriter text = new CharArrayWriter();
   7:     private DMetalink dMetalink;
   8:         ...
   9:         }
  10:         text.reset();
  11:     }

View Full Code Here
   1: 
   2:    private CharArrayWriter contents = new CharArrayWriter();
   3: 
   4:         ...
   5: 
   6:       contents.reset();
   7: 
   8:    }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.CharArrayWriter;
   3: import java.io.RandomAccessFile;
   4:         ...
   5:       FileInputStream fis = new FileInputStream(passwordFile);
   6:       CharArrayWriter writer = new CharArrayWriter();
   7:       int b;
   8:         ...
   9:       char[] password = writer.toCharArray();
  10:       writer.reset();
  11:       for(int n = 0; n < password.length; n ++)

View Full Code Here
   1: 
   2: import java.io.CharArrayWriter;
   3: 
   4:         ...
   5: 
   6:     private CharArrayWriter text = new CharArrayWriter();
   7: 
   8:         ...
   9:     {
  10:         text.reset();
  11:         return;

View Full Code Here

size

public int size()
Returns the current size of the buffer.
Returns:
an int representing the current size of the buffer.
Usages and Demos :

View More Examples of size()
   1:     private ServletResponse response;
   2:     private CharArrayWriter out0 = new CharArrayWriter();
   3:     private Writer out1;
   4:         ...
   5: 
   6:     private GSPResonseWriter(ServletResponse response, CharArrayWriter out, int max) {
   7:         super(out);
   8:         ...
   9:         if (!response.isCommitted()) {
  10:             response.setContentLength(out0.size());
  11:         }
  12:         ...
  13:         super.write(c);
  14:         if (out0.size() >= max) {

View Full Code Here
   1: 
   2: public class CharArrayWriterUpperCase extends CharArrayWriter {
   3: 
   4:         ...
   5: 
   6:     CharArrayWriter writer = new CharArrayWriter();
   7: 
   8:         ...
   9:     public int size() {
  10:         return (writer.size());
  11:     }

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.CharArrayWriter;
   3: import java.io.InputStream;
   4:         ...
   5:       
   6:       CharArrayWriter out = new CharArrayWriter(this.bytes.capacity());
   7:       Reader in = asReader();
   8:         ...
   9:       
  10:       this.chars = CharBuffer.wrap(out.toCharArray(), 0, out.size());
  11:       return this.chars.asReadOnlyBuffer();
  12:         ...
  13:       writeSourceBytes(out, cs);
  14:       this.bytes = ByteBuffer.wrap(out.getArray(), 0, out.size());

View Full Code Here
   1: import java.io.CharArrayReader;
   2: import java.io.CharArrayWriter;
   3: import java.io.InputStream;
   4:         ...
   5:       {
   6:         CharArrayWriter out = new CharArrayWriter(Character.MAX_VALUE);
   7:         final int maxChar = this.charset.name().startsWith("UTF-") 
   8:         ...
   9: 
  10:         while (out.size() < 10000) 
  11:         {
  12:         ...
  13: 
  14:         this.chars = chars = CharBuffer.wrap(out.toCharArray(), 0, out.size());

View Full Code Here

toCharArray

public char[] toCharArray()
Returns a copy of the input data.
Returns:
an array of chars copied from the input data.
Usages and Demos :

View More Examples of toCharArray()
   1: {
   2:   System.out.println("Started test of BufferedWriter and CharArrayWriter");
   3: 
   4:         ...
   5: 
   6:       CharArrayWriter caw = new CharArrayWriter(24);
   7:       BufferedWriter bw = new BufferedWriter(caw, 12);
   8:         ...
   9:       bw.write(buf, 0, 5);
  10:       if (caw.toCharArray().length != 0)
  11:         {
  12:         ...
  13: 
  14:       String str2 = new String(caw.toCharArray());

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.CharArrayWriter;
   3: import java.io.IOException;
   4:         ...
   5:   private URLEncoder urlEncoder_ ;  
   6:   private CharArrayWriter charArrayWriter;
   7:   private boolean writerAlreadyCalled;
   8:         ...
   9:   public char[] getPortletContent() {    
  10:     return charArrayWriter.toCharArray();
  11:   }

View Full Code Here
   1: 
   2: import java.io.CharArrayWriter;
   3: import java.io.PrintWriter;
   4:         ...
   5: {
   6:     private CharArrayWriter cw;
   7:     private PrintWriter writer;
   8:         ...
   9:     {
  10:         cw = new CharArrayWriter();
  11:         writer = new PrintWriter(cw);
  12:         ...
  13:         writer.flush();
  14:         return cw.toCharArray();

View Full Code Here
   1: 
   2: import java.io.CharArrayWriter;
   3: import java.io.PrintWriter;
   4:         ...
   5: {
   6:     private CharArrayWriter cw;
   7:     private PrintWriter writer;
   8:         ...
   9:     {
  10:         cw = new CharArrayWriter();
  11:         writer = new PrintWriter(cw);
  12:         ...
  13:         writer.flush();
  14:         return cw.toCharArray();

View Full Code Here
   1:     private ServletResponse response;
   2:     private CharArrayWriter out0 = new CharArrayWriter();
   3:     private Writer out1;
   4:         ...
   5: 
   6:     private GSPResonseWriter(ServletResponse response, CharArrayWriter out, int max) {
   7:         super(out);
   8:         ...
   9:         try {
  10:             out1.write(out0.toCharArray());
  11:             out0.reset();

View Full Code Here

toString

public String toString()
Converts input data to a string.
Overrides:
toString in interface Object
Returns:
the string.
Usages and Demos :

View More Examples of toString()
   1:     String zeichen, temp;
   2:     String responsestr = rswrapper.toString();
   3:     PrintWriter out = rs.getWriter();
   4:         ...
   5: class MeinResponseWrapper extends HttpServletResponseWrapper {
   6:   private CharArrayWriter antwort;
   7: 
   8:         ...
   9:     super(rs);
  10:     antwort = new CharArrayWriter();
  11:   }
  12:         ...
  13:   public String toString() {
  14:     return antwort.toString();

View Full Code Here
   1: 
   2: import java.io.CharArrayWriter;
   3: import java.io.InputStream;
   4:         ...
   5: 
   6:             CharArrayWriter writer = new CharArrayWriter();
   7:             PDFTextStripper stripper = new PDFTextStripper();
   8:         ...
   9: 
  10:             return writer.toString();
  11:         } finally {

View Full Code Here
   1: 
   2: import java.io.CharArrayWriter;
   3: import java.io.PrintWriter;
   4:         ...
   5: {
   6:     private CharArrayWriter output;
   7:     
   8:         ...
   9:     {
  10:         return output.toString();
  11:     }
  12:         ...
  13:         super(response);
  14:         output = new CharArrayWriter();

View Full Code Here
   1: public class CharResponseWrapper extends HttpServletResponseWrapper {
   2:     private CharArrayWriter output;
   3: 
   4:         ...
   5:     public String toString() {
   6:         return output.toString();
   7:     }
   8:         ...
   9:         super(response);
  10:         output = new CharArrayWriter();
  11:     }

View Full Code Here
   1: 
   2: import java.io.CharArrayWriter;
   3: import java.io.IOException;
   4:         ...
   5:     public String evaluate(String expression) throws IOException, ResourceNotFoundException, MethodInvocationException, ParseErrorException {
   6:         CharArrayWriter writer = new CharArrayWriter();
   7:         velocityEngine.evaluate(ctx, writer, "Error parsing " + expression, expression);
   8:         ...
   9: 
  10:         return writer.toString();
  11:     }

View Full Code Here

write

public void write(c[] ,
                  int off,
                  int len)
Writes characters to the buffer.
Parameters:
off - the start offset in the data
len - the number of chars that are written
Usages and Demos :

View More Examples of write(c[] ,int off,int len)
   1:     private void readDocument() {
   2:         CharArrayWriter writer = new CharArrayWriter();
   3:         char[] buf = new char[4096];
   4:         ...
   5:                     if (n > charsLimit - charsWritten) {
   6:                         writer.write(buf, 0, charsLimit - charsWritten);
   7:                         charsWritten = charsLimit;
   8:         ...
   9:                     } else {
  10:                         writer.write(buf, 0, n);
  11:                         charsWritten += n;

View Full Code Here
   1: import java.io.CharArrayReader;
   2: import java.io.CharArrayWriter;
   3: import java.io.IOException;
   4:         ...
   5:             char[] auxbuf = new char[1024]; 
   6:             CharArrayWriter wr = new CharArrayWriter(auxbuf.length);
   7:             int r = rd.read(auxbuf);
   8:         ...
   9:             {
  10:                wr.write(auxbuf, 0, r);
  11:                r = rd.read(auxbuf);

View Full Code Here
   1: 
   2:     private CharArrayWriter mMessageBuffer;
   3:     private Thread mMessageThread;
   4:         ...
   5: 
   6:         mMessageBuffer = new CharArrayWriter();
   7:     }
   8:         ...
   9: 
  10:         mMessageBuffer = new CharArrayWriter();
  11:     }
  12:         ...
  13:         }
  14:         mMessageBuffer.write(array, off, len);

View Full Code Here
   1:             
   2:             final CharArrayWriter    CharsOut = new CharArrayWriter(LengthHint);
   3:             final char[]            Buff = new char[LengthHint];
   4:         ...
   5:                 
   6:                 CharsOut.write(Buff, 0, CharsRead);
   7:                 CharsRead = In.read(Buff);
   8:             }
   9:             

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.CharArrayWriter;
   3: import java.io.File;
   4:         ...
   5:                 if (count > 0) {
   6:                     baos.write(buf, 0, count);
   7:                 }   
   8:         ...
   9:     private static char[] readChars(final File file) {
  10:         final CharArrayWriter caw = new CharArrayWriter();
  11:         try {
  12:         ...
  13:                 if (count > 0) {
  14:                     caw.write(buf, 0, count);

View Full Code Here

write

public void write(int c)
Writes a character to the buffer.
Overrides:
write in interface Writer
Usages and Demos :

View More Examples of write(int c)
   1:       chain.doFilter(request, wrapper);
   2:       CharArrayWriter caw = new CharArrayWriter();
   3:         ...
   4:       caw.write(wrapper.toString().substring(0, wrapper.toString().indexOf("</body>")-1));
   5:         ...
   6:       caw.write("<p>\n<center>" + messages.getString("Visitor") + "<font color='red'>" + counter.getCounter() + "</font></center>");
   7:         ...
   8:       caw.write("\n</body></html>");

View Full Code Here
   1:     boolean changedString = false;
   2:     CharArrayWriter writer = new CharArrayWriter(length);
   3:     
   4:         ...
   5:             changedString = true;
   6:             writer.write('&');
   7:         ...
   8:             writer.write('-');
   9:         } else {
  10:         ...
  11:             writer.write(current);

View Full Code Here
   1: import java.io.ByteArrayInputStream;
   2: import java.io.CharArrayWriter;
   3: import java.io.UnsupportedEncodingException;
   4:         ...
   5:         int len = text.length();
   6:         CharArrayWriter result = new CharArrayWriter(len);
   7:         for (int i=0; i<len; i++) {
   8:         ...
   9:                 && (text.charAt(i+2) == '>')) {
  10:             result.write(']');
  11:         ...
  12:             result.write(']');

View Full Code Here
   1: 
   2: import java.io.CharArrayWriter;
   3: import java.io.IOException;
   4:         ...
   5:     public static char[] removeQuotes(char []chars) {
   6:         CharArrayWriter caw = new CharArrayWriter();
   7:         for (int i = 0; i < chars.length; i++) {
   8:         ...
   9:                 chars[i+2] == '>') {
  10:                 caw.write('%');
  11:         ...
  12:                 caw.write('>');

View Full Code Here
   1: import java.io.BufferedReader;
   2: import java.io.CharArrayWriter;
   3: import java.io.File;
   4:         ...
   5:     private Writer mapout;
   6:     private CharArrayWriter servletout;
   7:         ...
   8:     private CharArrayWriter mappingout;
   9: 
  10:         ...
  11:         if (servletout != null) {
  12:             servletout.write("\n    <servlet>\n        <servlet-name>");

View Full Code Here

write

public void write(String str,
                  int off,
                  int len)
Write a portion of a string to the buffer.
Overrides:
write in interface Writer
Parameters:
str - String to be written from
off - Offset from which to start reading characters
len - Number of characters to be written
Usages and Demos :

View More Examples of write(String str,int off,int len)
   1:     private void readDocument() {
   2:         CharArrayWriter writer = new CharArrayWriter();
   3:         char[] buf = new char[4096];
   4:         ...
   5:                     if (n > charsLimit - charsWritten) {
   6:                         writer.write(buf, 0, charsLimit - charsWritten);
   7:                         charsWritten = charsLimit;
   8:         ...
   9:                     } else {
  10:                         writer.write(buf, 0, n);
  11:                         charsWritten += n;

View Full Code Here
   1: import java.io.CharArrayReader;
   2: import java.io.CharArrayWriter;
   3: import java.io.IOException;
   4:         ...
   5:             char[] auxbuf = new char[1024]; 
   6:             CharArrayWriter wr = new CharArrayWriter(auxbuf.length);
   7:             int r = rd.read(auxbuf);
   8:         ...
   9:             {
  10:                wr.write(auxbuf, 0, r);
  11:                r = rd.read(auxbuf);

View Full Code Here
   1: 
   2:     private CharArrayWriter mMessageBuffer;
   3:     private Thread mMessageThread;
   4:         ...
   5: 
   6:         mMessageBuffer = new CharArrayWriter();
   7:     }
   8:         ...
   9: 
  10:         mMessageBuffer = new CharArrayWriter();
  11:     }
  12:         ...
  13:         }
  14:         mMessageBuffer.write(array, off, len);

View Full Code Here
   1:             
   2:             final CharArrayWriter    CharsOut = new CharArrayWriter(LengthHint);
   3:             final char[]            Buff = new char[LengthHint];
   4:         ...
   5:                 
   6:                 CharsOut.write(Buff, 0, CharsRead);
   7:                 CharsRead = In.read(Buff);
   8:             }
   9:             

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.CharArrayWriter;
   3: import java.io.File;
   4:         ...
   5:                 if (count > 0) {
   6:                     baos.write(buf, 0, count);
   7:                 }   
   8:         ...
   9:     private static char[] readChars(final File file) {
  10:         final CharArrayWriter caw = new CharArrayWriter();
  11:         try {
  12:         ...
  13:                 if (count > 0) {
  14:                     caw.write(buf, 0, count);

View Full Code Here

writeTo

public void writeTo(Writer out)
            throws IOException
Writes the contents of the buffer to another character stream.
Parameters:
out - the output stream to write to
Throws:
IOException - If an I/O error occurs.
Usages and Demos :

View More Examples of writeTo(Writer out)
   1: 
   2: import java.io.CharArrayWriter;
   3: import java.io.PrintWriter;
   4:         ...
   5: {
   6:     private CharArrayWriter cw;
   7:     private PrintWriter writer;
   8:         ...
   9:     {
  10:         cw = new CharArrayWriter();
  11:         writer = new PrintWriter(cw);
  12:         ...
  13:         writer.flush();
  14:         cw.writeTo(out);

View Full Code Here
   1: 
   2: import java.io.CharArrayWriter;
   3: import java.io.PrintWriter;
   4:         ...
   5: {
   6:     private CharArrayWriter cw;
   7:     private PrintWriter writer;
   8:         ...
   9:     {
  10:         cw = new CharArrayWriter();
  11:         writer = new PrintWriter(cw);
  12:         ...
  13:         writer.flush();
  14:         cw.writeTo(out);

View Full Code Here
   1: 
   2: public class CharArrayWriterUpperCase extends CharArrayWriter {
   3: 
   4:         ...
   5: 
   6:     CharArrayWriter writer = new CharArrayWriter();
   7: 
   8:         ...
   9:     public void writeTo(Writer out) throws IOException {
  10:         writer.writeTo(out);
  11:     }

View Full Code Here
   1: import java.io.CharArrayReader;
   2: import java.io.CharArrayWriter;
   3: import java.io.File;
   4:         ...
   5: 
   6:   private CharArrayWriter _wsdlBuffer = new CharArrayWriter();
   7:   private boolean _wsdlGenerated = false;
   8:         ...
   9:     generateWSDL();
  10:     _wsdlBuffer.writeTo(w);
  11:   }
  12:         ...
  13:     generateSchema();
  14:     _schemaBuffer.writeTo(w);

View Full Code Here
   1: import java.io.BufferedReader;
   2: import java.io.CharArrayWriter;
   3: import java.io.File;
   4:         ...
   5:     private Writer mapout;
   6:     private CharArrayWriter servletout;
   7:         ...
   8:     private CharArrayWriter mappingout;
   9: 
  10:         ...
  11:             try {
  12:                 servletout.writeTo(mapout);

View Full Code Here