This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
files???
Posted by senthil on May 22, 2001 at 4:04 PM
class filereaderdemo{ public static void main(String[] arg)throws Exception{ FileReader fin=new FileReader("file.txt"); FileWriter fout=new FileWriter("file1.txt); int c; while((c=read())!=-1) { fout.write(c); } /*fout.close(); if this statement is commented the file is not written*/ } } When i use filewriter and filereader and if i dont close the filewriter object the file is not writtin,why is this? When i use FileInputStream and FileOutputStream and if i dont close the FileOutputStream object the file is still copied,why is that ? why should i close the writer object ?
Replies:
|