java.io

Class StringWriter

Implemented Interfaces:
Appendable, Closeable, Flushable

public class StringWriter
extends Writer

A character stream that collects its output in a string buffer, which can then be used to construct a string.

Closing a StringWriter has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.

Since:
JDK1.1

Field Summary

Fields inherited from class java.io.Writer

lock

Constructor Summary

StringWriter()
Create a new string writer, using the default initial string-buffer size.
StringWriter(int initialSize)
Create a new string writer, using the specified initial string-buffer size.

Method Summary

StringWriter
append(char c)
Appends the specified character to this writer.
StringWriter
append(CharSequence csq)
Appends the specified character sequence to this writer.
StringWriter
append(CharSequence csq, int start, int end)
Appends a subsequence of the specified character sequence to this writer.
void
close()
Closing a StringWriter has no effect.
void
flush()
Flush the stream.
StringBuffer
getBuffer()
Return the string buffer itself.
String
toString()
Return the buffer's current value as a string.
void
write(cbuf[] , int off, int len)
Write a portion of an array of characters.
void
write(int c)
Write a single character.
void
write(String str)
Write a string.
void
write(String str, int off, int len)
Write a portion of a string.

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

Constructor Details

StringWriter

public StringWriter()
Create a new string writer, using the default initial string-buffer size.
Usages and Demos :

View More Examples of StringWriter()
   1:     public StringResult() {
   2:         super(new StringWriter());
   3:     }
   4: 
   5:     public String toString() {

View Full Code Here
   1:     public final Writer transformBack(Reader r) {
   2:         return transformBack(r, new StringWriter());
   3:     }
   4:         ...
   5:     public final Writer transform(Reader r) {
   6:         return transform(r, new StringWriter());
   7:     }
   8: 
   9:     public String transform(String r) {

View Full Code Here
   1:         Transformer trans = TransformerFactory.newInstance().newTransformer(insrc);
   2:         StreamResult res = new StreamResult( new StringWriter());
   3:         trans.transform(new StreamSource(new StringReader(xml)), res );
   4:         return( res.getWriter().toString());
   5:     }

View Full Code Here
   1:     public StringIndentWriter() {
   2:         super(new StringWriter());
   3:     }
   4: 

View Full Code Here
   1:     public StringPrintWriter() {
   2:         super(new StringWriter());
   3:     }
   4: 
   5:     public StringPrintWriter(int initialSize) {

View Full Code Here

StringWriter

public StringWriter(int initialSize)
Create a new string writer, using the specified initial string-buffer size.
Parameters:
initialSize - an int specifying the initial size of the buffer.
Usages and Demos :

View More Examples of StringWriter(int initialSize)
   1: 
   2:         StringWriter buffer = new StringWriter(100);
   3:         buffer.write("Method type: ");
   4:         buffer.write(requestline.getMethod());
   5:         buffer.write("\r\n");

View Full Code Here
   1:     private static String stackToString(Throwable e){
   2:       java.io.StringWriter sw= new java.io.StringWriter(1024); 
   3:       java.io.PrintWriter pw= new java.io.PrintWriter(sw); 
   4:       e.printStackTrace(pw);
   5:       pw.close();

View Full Code Here
   1:     {
   2:       StringWriter sw = new StringWriter(2);
   3:       addHexAscii(b, sw);
   4:         ...
   5:       int len = bytes.length;
   6:       StringWriter sw = new StringWriter(len * 2);
   7:       for (int i = 0; i < len; ++i)
   8:     addHexAscii(bytes[i], sw);
   9:       return sw.toString();

View Full Code Here
   1:       private final Throwable tracer = new Throwable();
   2:       private final StringWriter sw = new StringWriter(1024);
   3:       private final PrintWriter out = new PrintWriter(sw, false);
   4: 

View Full Code Here
   1:     public static final String getStackTrace(Throwable exception) {
   2:         StringWriter buffer = new StringWriter(1000);
   3:         exception.printStackTrace(new PrintWriter(buffer));
   4:         return buffer.toString();
   5:     }

View Full Code Here

Method Details

append

public StringWriter 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.StringReader;
   2: import java.io.StringWriter;
   3: import java.io.UnsupportedEncodingException;
   4:         ...
   5:             Reader  reader = new InputStreamReader(is, encoding);
   6:             StringWriter content = new StringWriter();
   7:             char ch[] = new char[4096];
   8:         ...
   9:             if(node.getNodeType() == Node.TEXT_NODE)
  10:                 content.append(((Text)node).getData());
  11:         }

View Full Code Here
   1: import java.io.PrintWriter;
   2: import java.io.StringWriter;
   3: 
   4:         ...
   5:       {
   6:         str.append(HEX.charAt(buf[i+off] >>> 4 & 0x0F));
   7:         ...
   8:         str.append(HEX.charAt(buf[i+off] & 0x0F));
   9:       }
  10:         ...
  11:       {
  12:         str.append(HEX.charAt(buf[i+off] >>> 4 & 0x0F));

View Full Code Here
   1:     sb.append(lineString.substring(0, column));
   2:     sb.append(comment);
   3:     if (comment.endsWith("\n")) {
   4:         ...
   5:     }
   6:     sb.append(lineString.substring(column));
   7:     javaFileLines.set(linenumber, sb.toString());
   8:         ...
   9: 
  10:     StringWriter sw = new StringWriter();
  11:     PrintWriter pw = new PrintWriter(sw);

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.io.StringWriter;
   3: import java.io.IOException;
   4:         ...
   5:             final StringBuffer  buffer = new StringBuffer();
   6:             buffer.append('(');
   7:         ...
   8:             buffer.append(x);
   9:             buffer.append(',');
  10:         ...
  11:             buffer.append(y);

View Full Code Here

append

public StringWriter 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.StringReader;
   2: import java.io.StringWriter;
   3: import java.io.UnsupportedEncodingException;
   4:         ...
   5:             Reader  reader = new InputStreamReader(is, encoding);
   6:             StringWriter content = new StringWriter();
   7:             char ch[] = new char[4096];
   8:         ...
   9:             if(node.getNodeType() == Node.TEXT_NODE)
  10:                 content.append(((Text)node).getData());
  11:         }

View Full Code Here
   1: import java.io.PrintWriter;
   2: import java.io.StringWriter;
   3: 
   4:         ...
   5:       {
   6:         str.append(HEX.charAt(buf[i+off] >>> 4 & 0x0F));
   7:         ...
   8:         str.append(HEX.charAt(buf[i+off] & 0x0F));
   9:       }
  10:         ...
  11:       {
  12:         str.append(HEX.charAt(buf[i+off] >>> 4 & 0x0F));

View Full Code Here
   1:     sb.append(lineString.substring(0, column));
   2:     sb.append(comment);
   3:     if (comment.endsWith("\n")) {
   4:         ...
   5:     }
   6:     sb.append(lineString.substring(column));
   7:     javaFileLines.set(linenumber, sb.toString());
   8:         ...
   9: 
  10:     StringWriter sw = new StringWriter();
  11:     PrintWriter pw = new PrintWriter(sw);

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.io.StringWriter;
   3: import java.io.IOException;
   4:         ...
   5:             final StringBuffer  buffer = new StringBuffer();
   6:             buffer.append('(');
   7:         ...
   8:             buffer.append(x);
   9:             buffer.append(',');
  10:         ...
  11:             buffer.append(y);

View Full Code Here

append

public StringWriter 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
Usages and Demos :

View More Examples of append(CharSequence csq,int start,int end)
   1: import java.io.PrintWriter;
   2: import java.io.StringWriter;
   3: 
   4:         ...
   5:           str.append(prefix);
   6:         str.append(Util.formatInt(i+off, 16, 8));
   7:         str.append("  ");
   8:         ...
   9:     buf = buf.duplicate();
  10:     StringWriter str = new StringWriter ();
  11:     PrintWriter out = new PrintWriter (str);

View Full Code Here

close

public void close()
            throws IOException
Closing a StringWriter has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.
Specified by:
close in interface Closeable
Overrides:
close in interface Writer
Usages and Demos :

View More Examples of close()
   1:    }
   2:    StringWriter out = new StringWriter();
   3: 
   4:         ...
   5:             out.write(buffer, 0, numchars);
   6:           out.close();
   7:    }
   8:    catch (IOException e) {
   9:      return "IO Error reading file '"+actualFileName+"'.\n";

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.StringWriter;
   3: import java.io.PrintWriter;
   4:         ...
   5:       WordDocument wd = new WordDocument(is);
   6:       StringWriter docTextWriter = new StringWriter();
   7:       wd.writeAllText(new PrintWriter(docTextWriter));
   8:         ...
   9:       docTextWriter.close();
  10:       bodyText = docTextWriter.toString();

View Full Code Here
   1:         }
   2:         StringWriter out = new StringWriter();
   3: 
   4:         ...
   5:             }
   6:             out.close();
   7:         } catch (IOException e) {
   8:             return "IO Error reading file '" + actualFileName + "'.\n";
   9:         }

View Full Code Here
   1:                          new Properties());
   2:     StringWriter result = new StringWriter();
   3:     Token token = null;
   4:         ...
   5:     }
   6:     result.close();
   7:     return result.toString();
   8:   }

View Full Code Here
   1:       new LatexToUnicode(source, manager_, new Properties());
   2:     StringWriter result = new StringWriter();
   3:     Token token = null;
   4:         ...
   5:     }
   6:     result.close();
   7:     return result.toString();
   8:   }

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: import java.io.StringWriter;
   3: 
   4:         ...
   5:     private AbbreviatedRdfXmlWriter myWriter;;
   6:     private StringWriter myStringWriter;
   7:     
   8:         ...
   9:     { 
  10:         myStringWriter = new StringWriter();
  11:         myWriter = new AbbreviatedRdfXmlWriter( myStringWriter );
  12:         ...
  13:     {
  14:         myStringWriter.flush();

View Full Code Here
   1: 
   2: import java.io.StringWriter;
   3: import junit.framework.TestCase;
   4:         ...
   5:             XMLOutputFactory f = XMLOutputFactory.newInstance();
   6:             StringWriter sw = new StringWriter();
   7:             XMLStreamWriter writer = f.createXMLStreamWriter(sw);
   8:         ...
   9:             writer.writeEndDocument();
  10:             writer.flush();
  11:         ...
  12:             sw.flush();

View Full Code Here
   1: 
   2: import java.io.StringWriter;
   3: 
   4:         ...
   5:         }
   6:         StringWriter writer2 = new StringWriter();
   7: 
   8:         ...
   9:         impl.writeRssOutput(writer, "test");
  10:         writer.flush();
  11:         ...
  12:         writer2.flush();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.StringWriter;
   3: import java.io.Writer;
   4:         ...
   5:     private Writer writer;
   6:     private StringWriter body;
   7:     private boolean afterBody = false;
   8:         ...
   9:         if (bean.usesBody()) {
  10:             this.body = new StringWriter();
  11:         }
  12:         ...
  13:     public void flush() throws IOException {
  14:         writer.flush();

View Full Code Here
   1: 
   2: import java.io.StringWriter;
   3: import java.util.Iterator;
   4:         ...
   5: 
   6:         StringWriter pw = new StringWriter();
   7: 
   8:         ...
   9: 
  10:             pw.flush();
  11:             pw.close();

View Full Code Here

getBuffer

public StringBuffer getBuffer()
Return the string buffer itself.
Returns:
StringBuffer holding the current buffer value.
Usages and Demos :

View More Examples of getBuffer()
   1: import java.io.StringReader;
   2: import java.io.StringWriter;
   3: 
   4:         ...
   5:     {
   6:         StringWriter writer = new StringWriter();
   7: 
   8:         ...
   9:             "@test1@@test2@",
  10:             writer.getBuffer().toString());
  11:     }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.StringWriter;
   3: import java.io.Writer;
   4:         ...
   5:  public String format(Object obj) throws IOException {
   6:    StringWriter w = new StringWriter() ;
   7:    format(w, obj) ;
   8:         ...
   9:    return w.getBuffer().toString() ;
  10:   }

View Full Code Here
   1: import java.io.PrintWriter;
   2: import java.io.StringWriter;
   3: 
   4:         ...
   5:     private String getStackTraceAsString(Throwable t) {
   6:         StringWriter stringWriter = new StringWriter();
   7:         if (t != null) {
   8:         ...
   9:             t.printStackTrace(new PrintWriter(stringWriter));
  10:             return stringWriter.getBuffer().toString();
  11:         } else {

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.StringWriter;
   3: import java.io.Writer;
   4:         ...
   5:  public String format(Object obj) throws IOException {
   6:     StringWriter w = new StringWriter() ;
   7:     List list = (List) obj ;
   8:         ...
   9:     }
  10:     return w.getBuffer().toString() ;
  11:   }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.StringWriter;
   3: import java.io.Writer;
   4:         ...
   5:   public String  format(Object obj) throws IOException {
   6:     StringWriter w = new StringWriter() ;
   7:     format(w, obj) ;
   8:         ...
   9:     return w.getBuffer().toString() ;
  10:   }

View Full Code Here

toString

public String toString()
Return the buffer's current value as a string.
Overrides:
toString in interface Object
Usages and Demos :

View More Examples of toString()
   1: import java.io.PrintWriter;
   2: import java.io.StringWriter;
   3: import java.util.Collections;
   4:         ...
   5:         
   6:         StringWriter stringWriter = new StringWriter();
   7:         PrintWriter printWriter =
   8:         ...
   9:             "One message\r\n",
  10:             stringWriter.toString());
  11:     }

View Full Code Here
   1:     private TextBasedTestListener testListener;
   2:     private StringWriter stringWriter;
   3: 
   4:         ...
   5:     protected void setUp() throws Exception {
   6:         stringWriter = new StringWriter();
   7:         testListener =
   8:         ...
   9:         testListener.startTest(this);
  10:         assertEquals(".", stringWriter.toString());
  11:     }
  12:         ...
  13:         testListener.addFailure(this, new AssertionFailedError());
  14:         assertEquals("F", stringWriter.toString());

View Full Code Here
   1: import java.io.PrintWriter;
   2: import java.io.StringWriter;
   3: 
   4:         ...
   5:     public void addStackTraceDescription(TestReport report){
   6:         StringWriter trace = new StringWriter();
   7:         printStackTrace(new PrintWriter(trace));
   8:         ...
   9:           (TestReport.ENTRY_KEY_ERROR_CONDITION_STACK_TRACE,
  10:            trace.toString());
  11:     }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.StringWriter;
   3: import java.io.Writer;
   4:         ...
   5: 
   6:     private final StringWriter writer;
   7: 
   8:         ...
   9:         {
  10:             writer = new StringWriter();
  11:             writer.write((String) message);
  12:         ...
  13:     {
  14:         return writer.toString();

View Full Code Here
   1: 
   2: import java.io.StringWriter;
   3: 
   4:         ...
   5:         {
   6:             StringWriter strWriter = new StringWriter();
   7:             GOMOutputWriter writer = new GOMStaxWriter(strWriter);
   8:         ...
   9:             assertEquals("<?xml version='1.0' encoding='UTF-8'?><test/>",
  10:                     strWriter.toString());
  11:         }
  12:         ...
  13:             assertEquals("<?xml version='1.0' encoding='UTF-8'?>", strWriter
  14:                     .toString());

View Full Code Here

write

public void write(cbuf[] ,
                  int off,
                  int len)
Write a portion of an array of characters.
Overrides:
write in interface Writer
Parameters:
off - Offset from which to start writing characters
len - Number of characters to write
Usages and Demos :

View More Examples of write(cbuf[] ,int off,int len)
   1:    }
   2:    StringWriter out = new StringWriter();
   3: 
   4:         ...
   5:      while((numchars = in.read(buffer)) != -1)
   6:             out.write(buffer, 0, numchars);
   7:           out.close();
   8:    }
   9:    catch (IOException e) {

View Full Code Here
   1:         }
   2:         StringWriter out = new StringWriter();
   3: 
   4:         ...
   5:             while((numchars = in.read(buffer)) != -1) {
   6:                 out.write(buffer, 0, numchars);
   7:             }
   8:             out.close();
   9:         } catch (IOException e) {

View Full Code Here
   1:             char[] buf = new char[8192];
   2:             StringWriter sw = new StringWriter(isize);
   3:             try {
   4:         ...
   5:                 while ((n = reader.read(buf, 0, buf.length)) != -1){
   6:                     sw.write(buf, 0, n);
   7:                 }
   8:                 return sw.toString();
   9:             } finally {

View Full Code Here
   1:               BufferedReader br = new BufferedReader(isr);
   2:               StringWriter sw = new StringWriter();
   3:               char buf[] = new char[1024];
   4:         ...
   5:               while ((count = br.read(buf, 0, 1024)) != -1) {
   6:                 sw.write(buf, 0, count);
   7:               }
   8:               System.out.println("Done Loading");
   9:               updateTextArea(textArea, sw.toString());

View Full Code Here
   1: import java.io.InputStreamReader;
   2: import java.io.StringWriter;
   3: import java.net.MalformedURLException;
   4:         ...
   5:         String arg = args[0].itemAt(0).getStringValue();
   6:         StringWriter sw;
   7:         try {
   8:         ...
   9:                 isr = new InputStreamReader(url.openStream());
  10:             sw = new StringWriter();
  11:             char[] buf = new char[1024];
  12:         ...
  13:             while ((len = isr.read(buf)) > 0) {
  14:                 sw.write(buf, 0, len);

View Full Code Here

write

public void write(int c)
Write a single character.
Overrides:
write in interface Writer
Usages and Demos :

View More Examples of write(int c)
   1: import java.io.IOException;
   2: import java.io.StringWriter;
   3: 
   4:         ...
   5:             BufferedWriter bw = new BufferedWriter(fw);
   6:             bw.write(fw.getEncoding());
   7:         ...
   8:             bw.write(stream);
   9:             bw.close();
  10:         ...
  11:         } catch (IOException ioe) {
  12:             StringWriter sw = new StringWriter();

View Full Code Here
   1: 
   2: import java.io.StringWriter;
   3: import java.util.Date;
   4:         ...
   5:     public String getThrownToString() {
   6:         StringWriter sw = new StringWriter();
   7:         Throwable t = getThrown();
   8:         ...
   9:             String tStr = t.toString();
  10:             sw.write(tStr);
  11:             if (t.getMessage() != null && t.getMessage().length() > 0 &&
  12:         ...
  13:                     !tStr.endsWith(t.getMessage())) {
  14:                 sw.write("\nMessage: ");

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.StringWriter;
   3: import java.net.URI;
   4:         ...
   5:         geom.setUserData("EPSG:4326");
   6:         final StringWriter writer = new StringWriter();
   7:         
   8:         ...
   9:             public void characters(String s) throws IOException {
  10:                 writer.write(s);
  11:             }
  12:         ...
  13:             public void endElement(URI namespaceURI, String localName) throws IOException {
  14:                 writer.write("</"+localName+">");

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.StringWriter;
   3: import java.util.Iterator;
   4:         ...
   5:         Element msgElem = msgTree;
   6:         StringWriter writer = new StringWriter(100);
   7:         ...
   8:         writer.write("<" + msgTree.getQualifiedName());
   9:         if (!msgTree.getNamespaceURI().equals(""))
  10:         ...
  11:             writer.write(" xmlns=\"" + msgTree.getNamespaceURI() + "\"");

View Full Code Here
   1: 
   2: import java.io.StringWriter;
   3: import java.text.ParseException;
   4:         ...
   5:   public static String buildDateTime(Calendar cal) {
   6:     StringWriter out = new StringWriter();
   7:         ...
   8:     out.write("" + cal.get(Calendar.YEAR));
   9:         ...
  10:     out.write("-");

View Full Code Here

write

public void write(String str)
Write a string.
Overrides:
write in interface Writer
Usages and Demos :

View More Examples of write(String str)
   1: import java.io.IOException;
   2: import java.io.StringWriter;
   3: 
   4:         ...
   5:             BufferedWriter bw = new BufferedWriter(fw);
   6:             bw.write(fw.getEncoding());
   7:         ...
   8:             bw.write(stream);
   9:             bw.close();
  10:         ...
  11:         } catch (IOException ioe) {
  12:             StringWriter sw = new StringWriter();

View Full Code Here
   1: 
   2: import java.io.StringWriter;
   3: import java.util.Date;
   4:         ...
   5:     public String getThrownToString() {
   6:         StringWriter sw = new StringWriter();
   7:         Throwable t = getThrown();
   8:         ...
   9:             String tStr = t.toString();
  10:             sw.write(tStr);
  11:             if (t.getMessage() != null && t.getMessage().length() > 0 &&
  12:         ...
  13:                     !tStr.endsWith(t.getMessage())) {
  14:                 sw.write("\nMessage: ");

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.StringWriter;
   3: import java.net.URI;
   4:         ...
   5:         geom.setUserData("EPSG:4326");
   6:         final StringWriter writer = new StringWriter();
   7:         
   8:         ...
   9:             public void characters(String s) throws IOException {
  10:                 writer.write(s);
  11:             }
  12:         ...
  13:             public void endElement(URI namespaceURI, String localName) throws IOException {
  14:                 writer.write("</"+localName+">");

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.StringWriter;
   3: import java.util.Iterator;
   4:         ...
   5:         Element msgElem = msgTree;
   6:         StringWriter writer = new StringWriter(100);
   7:         ...
   8:         writer.write("<" + msgTree.getQualifiedName());
   9:         if (!msgTree.getNamespaceURI().equals(""))
  10:         ...
  11:             writer.write(" xmlns=\"" + msgTree.getNamespaceURI() + "\"");

View Full Code Here
   1: 
   2: import java.io.StringWriter;
   3: import java.text.ParseException;
   4:         ...
   5:   public static String buildDateTime(Calendar cal) {
   6:     StringWriter out = new StringWriter();
   7:         ...
   8:     out.write("" + cal.get(Calendar.YEAR));
   9:         ...
  10:     out.write("-");

View Full Code Here

write

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

View More Examples of write(String str,int off,int len)
   1:    }
   2:    StringWriter out = new StringWriter();
   3: 
   4:         ...
   5:      while((numchars = in.read(buffer)) != -1)
   6:             out.write(buffer, 0, numchars);
   7:           out.close();
   8:    }
   9:    catch (IOException e) {

View Full Code Here
   1:         }
   2:         StringWriter out = new StringWriter();
   3: 
   4:         ...
   5:             while((numchars = in.read(buffer)) != -1) {
   6:                 out.write(buffer, 0, numchars);
   7:             }
   8:             out.close();
   9:         } catch (IOException e) {

View Full Code Here
   1:             char[] buf = new char[8192];
   2:             StringWriter sw = new StringWriter(isize);
   3:             try {
   4:         ...
   5:                 while ((n = reader.read(buf, 0, buf.length)) != -1){
   6:                     sw.write(buf, 0, n);
   7:                 }
   8:                 return sw.toString();
   9:             } finally {

View Full Code Here
   1:               BufferedReader br = new BufferedReader(isr);
   2:               StringWriter sw = new StringWriter();
   3:               char buf[] = new char[1024];
   4:         ...
   5:               while ((count = br.read(buf, 0, 1024)) != -1) {
   6:                 sw.write(buf, 0, count);
   7:               }
   8:               System.out.println("Done Loading");
   9:               updateTextArea(textArea, sw.toString());

View Full Code Here
   1: import java.io.InputStreamReader;
   2: import java.io.StringWriter;
   3: import java.net.MalformedURLException;
   4:         ...
   5:         String arg = args[0].itemAt(0).getStringValue();
   6:         StringWriter sw;
   7:         try {
   8:         ...
   9:                 isr = new InputStreamReader(url.openStream());
  10:             sw = new StringWriter();
  11:             char[] buf = new char[1024];
  12:         ...
  13:             while ((len = isr.read(buf)) > 0) {
  14:                 sw.write(buf, 0, len);

View Full Code Here