import java.io.*; public class Writer_OutputStream { public static void main(String args[]) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); OutputStreamWriter ow = new OutputStreamWriter(out); ow.write("Constructor argument is ByteArrayOutStream object"); ow.flush(); System.out.println(out.toString()); FileOutputStream flt = new FileOutputStream(new File("rose.txt")); ow = new OutputStreamWriter(flt); ow.append("welcome to www.codingdiary.com"); System.out .println("\nAppended sequence of characters will generate in a file rose.txt"); ow.flush(); } }