Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Folder

Status
Not open for further replies.

okiiyama

IS-IT--Management
Jan 3, 2003
269
US
How do I create a folder in java?

DO I use java.io.file? and if so what method?
 
mkdir will create w file with name containing the string passed in constructor

Ion Filipski
1c.bmp
 
Like this - new File("mydir").mkdir();

Bear in mind java.io.File does not throw any execptions, so if the mkdir() call fails - you will not be explicitly notified. You must programmatically check it afterwards using :

Code:
File f = new File("mydir");
if (f.exists() && (!f.isFile())) {
  // OK
} else {
  // Something went wrong 
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top