0

in netbeans 6.7 i'm trying to create a text file,say man.txt
using code "file fr=new file("man.txt")..
code executed fine..but i can't see the file man.txt anywhere

where the file is created..pls help me

4
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by eldhoksuresh
0

>code executed fine..but i can't see the file man.txt anywhere..

Correct me if I am wrong. OP wants to create a file using java.io.File class. There are two instance methods namely - createNewFile() and createTempFile() which create a file.

Following code creates a new File instance by converting the given pathname string into an abstract pathname.

File f=new File("man.txt");
0

The File class is "An abstract representation of file and directory pathnames." (Java API ref). Just because you have an an abstract representation of a file name, that doesn't mean you necessarily have an actual file on disk. The actual file will appear when you open some kind of output stream to the File and write something.
Alternatively you can use the afore-mentioned createNewFile() to create an actual empty file on disk (createTempFile() is different, it's a static factory method).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.