Sunday, 11 June 2017

Java Tutorial : Java IO (CharArrayWriter(int initialSize) Constructor) ~ foundjava


Click here to watch in Youtube :

CharArrayWriterDemo.java
import java.io.CharArrayWriter;
import java.io.IOException;

/*
 * public CharArrayWriter(int initialSize)
 * 
 * Parameters: 
 * ----------
 * 
 * initialSize - an int specifying the initial buffer
 * size.
 */

public class CharArrayWriterDemo
{

    public static void main(String[] args) throws IOException
    {

        int initialSize = 1024;
        /*
         * Creates a new CharArrayWriter with the specified
         * initial size.
         */
        CharArrayWriter charArrayWriter = new CharArrayWriter(initialSize);

        charArrayWriter.write("Welcome to India.");

        /*
         * Returns: an array of chars copied from the input
         * data.
         */
        char[] charArray = charArrayWriter.toCharArray();

        for (char c : charArray)
        {
            System.out.print(c);
        }

    }
}
Output
Welcome to India.
Click the below link to download the code:

CLICK HERE

No comments:

Post a Comment