CharArrayWriter In Java Example

Chapter: Java I/O Last Updated: 13-04-2016 15:30:11 UTC

Program:

            /* ............... START ............... */
                
import java.io.CharArrayWriter;

public class JavaCharArrayWriter {
	public static void main(String[] args) {

		CharArrayWriter charWriter = new CharArrayWriter();

		try {

			String str = "Welcome To JavaScan.com";
			charWriter.write(str);

			char[] chars = charWriter.toCharArray();
			for (char c : chars) {
				System.out.print(c);
			}

		} catch (Exception ex) {
			System.out.println(ex.getMessage());
		}

		charWriter.close();
	}
}
                /* ............... END ............... */
        

Output

Welcome To JavaScan.com

Notes:

  • The java.io.CharArrayWriter.toCharArray() method returns a array of character from this writer.

Tags

CharArrayWriter , Java, Java I/O

Similar Programs Chapter Last Updated
Hidden File Check In Java Example Java I/O 20-06-2016
FileWriter In Java Example Java I/O 21-07-2016
FileReader In Java Example Java I/O 21-07-2016
FileOutputStream In Java Example Java I/O 21-07-2016
FileInputStream In Java Example Java I/O 21-07-2016
DataOutputStream In Java Example Java I/O 21-07-2016
DataInputStream In Java Example Java I/O 21-07-2016
CharArrayReader In Java Example Java I/O 21-07-2016
ByteArrayOutputStream In Java Example Java I/O 21-07-2016
ByteArrayInputStream In Java Example Java I/O 21-07-2016
BufferedWriter In Java Example Java I/O 21-07-2016
BufferedReader In Java Example Java I/O 21-07-2016
BufferedOutputStream In Java Example Java I/O 21-07-2016
BufferedInputStream In Java Example Java I/O 21-07-2016
ProcessBuilder To Make System Calls In Java Java I/O 19-08-2017

1