IT. Expert System.

Android Reference

CharArrayWriter


java.io

Class CharArrayWriter

  • All Implemented Interfaces:
    Closeable, Flushable, Appendable, AutoCloseable


    public class CharArrayWriter
    extends Writer
    A specialized Writer for class for writing content to an (internal) char array. As bytes are written to this writer, the char array may be expanded to hold more characters. When the writing is considered to be finished, a copy of the char array can be requested from the class.
    See Also:
    CharArrayReader
    • Field Summary

      Fields
      Modifier and Type Field and Description
      protected char[] buf
      The buffer for characters.
      protected int count
      The ending index of the buffer.
    • Constructor Summary

      Constructors
      Constructor and Description
      CharArrayWriter()
      Constructs a new CharArrayWriter which has a buffer allocated with the default size of 32 characters.
      CharArrayWriter(int initialSize)
      Constructs a new CharArrayWriter which has a buffer allocated with the size of initialSize characters.
    • Method Summary

      Methods
      Modifier and Type Method and Description
      CharArrayWriter append(char c)
      Appends a char c to the CharArrayWriter.
      CharArrayWriter append(CharSequence csq)
      Appends a CharSequence to the CharArrayWriter.
      CharArrayWriter append(CharSequence csq, int start, int end)
      Append a subsequence of a CharSequence to the CharArrayWriter.
      void close()
      Closes this writer.
      void flush()
      Flushes this writer.
      void reset()
      Resets this writer.
      int size()
      Returns the size of this writer, that is the number of characters it stores.
      char[] toCharArray()
      Returns the contents of the receiver as a char array.
      String toString()
      Returns the contents of this CharArrayWriter as a string.
      void write(char[] buffer, int offset, int len)
      Writes count characters starting at offset in c to this writer.
      void write(int oneChar)
      Writes the specified character oneChar to this writer.
      void write(String str, int offset, int count)
      Writes count characters starting at offset from the string str to this CharArrayWriter.
      void writeTo(Writer out)
      Writes the contents of this CharArrayWriter to another Writer.
    • Field Detail

      • buf

        protected char[] buf
        The buffer for characters.
      • count

        protected int count
        The ending index of the buffer.
    • Constructor Detail

      • CharArrayWriter

        public CharArrayWriter()
        Constructs a new CharArrayWriter which has a buffer allocated with the default size of 32 characters. This buffer is also used as the lock to synchronize access to this writer.
      • CharArrayWriter

        public CharArrayWriter(int initialSize)
        Constructs a new CharArrayWriter which has a buffer allocated with the size of initialSize characters. The buffer is also used as the lock to synchronize access to this writer.
        Parameters:
        initialSize - the initial size of this CharArrayWriters buffer.
        Throws:
        IllegalArgumentException - if initialSize < 0.
    • Method Detail

      • close

        public void close()
        Closes this writer. The implementation in CharArrayWriter does nothing.
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in class Writer
      • flush

        public void flush()
        Flushes this writer. The implementation in CharArrayWriter does nothing.
        Specified by:
        flush in interface Flushable
        Specified by:
        flush in class Writer
      • reset

        public void reset()
        Resets this writer. The current write position is reset to the beginning of the buffer. All written characters are lost and the size of this writer is set to 0.
      • size

        public int size()
        Returns the size of this writer, that is the number of characters it stores. This number changes if this writer is reset or when more characters are written to it.
        Returns:
        this CharArrayWriter's current size in characters.
      • toCharArray

        public char[] toCharArray()
        Returns the contents of the receiver as a char array. The array returned is a copy and any modifications made to this writer after calling this method are not reflected in the result.
        Returns:
        this CharArrayWriter's contents as a new char array.
      • toString

        public String toString()
        Returns the contents of this CharArrayWriter as a string. The string returned is a copy and any modifications made to this writer after calling this method are not reflected in the result.
        Overrides:
        toString in class Object
        Returns:
        this CharArrayWriters contents as a new string.
      • write

        public void write(char[] buffer,
                 int offset,
                 int len)
        Writes count characters starting at offset in c to this writer.
        Specified by:
        write in class Writer
        Parameters:
        buffer - the non-null array containing characters to write.
        offset - the index of the first character in buf to write.
        len - maximum number of characters to write.
        Throws:
        IndexOutOfBoundsException - if offset < 0 or len < 0, or if offset + len is bigger than the size of c.
      • write

        public void write(int oneChar)
        Writes the specified character oneChar to this writer. This implementation writes the two low order bytes of the integer oneChar to the buffer.
        Overrides:
        write in class Writer
        Parameters:
        oneChar - the character to write.
      • write

        public void write(String str,
                 int offset,
                 int count)
        Writes count characters starting at offset from the string str to this CharArrayWriter.
        Overrides:
        write in class Writer
        Parameters:
        str - the non-null string containing the characters to write.
        offset - the index of the first character in str to write.
        count - the number of characters from str to write.
        Throws:
        NullPointerException - if str is null.
        StringIndexOutOfBoundsException - if offset < 0 or count < 0, or if offset + count is bigger than the length of str.
      • writeTo

        public void writeTo(Writer out)
                     throws IOException
        Writes the contents of this CharArrayWriter to another Writer. The output is all the characters that have been written to the receiver since the last reset or since it was created.
        Parameters:
        out - the non-null Writer on which to write the contents.
        Throws:
        NullPointerException - if out is null.
        IOException - if an error occurs attempting to write out the contents.
      • append

        public CharArrayWriter append(char c)
        Appends a char c to the CharArrayWriter. The method works the same way as write(c).
        Specified by:
        append in interface Appendable
        Overrides:
        append in class Writer
        Parameters:
        c - the character appended to the CharArrayWriter.
        Returns:
        this CharArrayWriter.
      • append

        public CharArrayWriter append(CharSequence csq)
        Appends a CharSequence to the CharArrayWriter. The method works the same way as write(csq.toString()). If csq is null, then it will be substituted with the string "null".
        Specified by:
        append in interface Appendable
        Overrides:
        append in class Writer
        Parameters:
        csq - the CharSequence appended to the CharArrayWriter, may be null.
        Returns:
        this CharArrayWriter.
      • append

        public CharArrayWriter append(CharSequence csq,
                             int start,
                             int end)
        Append a subsequence of a CharSequence to the CharArrayWriter. The first and last characters of the subsequence are specified by the parameters start and end. A call to CharArrayWriter.append(csq) works the same way as CharArrayWriter.write(csq.subSequence(start, end).toString). If csq is null, then it will be substituted with the string "null".
        Specified by:
        append in interface Appendable
        Overrides:
        append in class Writer
        Parameters:
        csq - the CharSequence appended to the CharArrayWriter, may be null.
        start - the index of the first character in the CharSequence appended to the CharArrayWriter.
        end - the index of the character after the last one in the CharSequence appended to the CharArrayWriter.
        Returns:
        this CharArrayWriter.
        Throws:
        IndexOutOfBoundsException - if start < 0, end < 0, start > end, or if end is greater than the length of csq.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 726 / . Delta: 0.04227 с