• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to close a file  RSS feed

 
Sakthi Kani
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a piece of below code to write the details into output file,

I am able to close out object, but the tempFile.

Can anyone tell me how to close this file?


Thanks in advance.
JCE: Please Use Code Tags
 
Sakthi Kani
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couldnt close the tempFile.
 
Joe Ess
Bartender
Posts: 9426
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The File object in Java is provided for getting file details (time modified, file size, renaming, deleting). It is not necessary to create one before writing to a file. Since you don't really "open" a File object, it's not necessary to "close" it.
Take a few minutes and look through the chapter on IO from the Java Tutorial. It will give you a good introduction.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!