public class Write_File {
public static void main(String args[]) throws IOException {
File flt = new File("codingdiary.doc");
FileWriter wrt = new FileWriter(flt);
CharSequence cq = "welcome to future";
wrt.append(cq);
wrt.flush();
System.out.println("Output is generated in a file codingdiary.doc");
flt = new File("sateesh.txt");
PrintWriter out = new PrintWriter(new BufferedWriter(
new FileWriter(flt)));
out.print("Welcome to java programming");
out.flush();
System.out.println("Output is generated in a file sateesh.txt");
flt = new File("rachel_weisz");
flt.createNewFile();
System.out.println("An unknown extension file rachel_weisz is created");
CharArrayWriter ch = new CharArrayWriter();
cq = "newstrackindia.com";
ch.append(cq);
ch.flush();
System.out.println(ch.toString());
}
}
No comments:
Post a Comment