its for text
new file
new file writer
write rite rite
flush (ensures on disk not in memory)
close
reader can asynch read files
writer creates file if not in existence
an example
Usage of FileWriter can be explained as follows :
File file = new File("fileWrite2.txt"); FileWriter fw = new FileWriter(file); for(int i=0;i<10;i++){ fw.write("Soham is Just Awesome : "+i); fw.flush(); } fw.close(); |
int c; FileReader fread = new FileReader("xanadu.txt"); FileWriter fwrite = new FileWriter("characteroutput.txt"); while ((c = fread.read()) != -1) fwrite.write(c); |
No comments:
Post a Comment