• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I create a Data folder in my C: Drive using my Java program  RSS feed

 
Xavier Downing
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My assignment requires that I use exception handling to create a directory and file if necessary.

I was able to create a Cata\inventory.dat file, provided that there's an existing Data folder (directory) in my C: drive; however, I have a feeling that the assignment wants me to create an actual Data folder if one is not available. When I remove the Data folder from my C: drive, I get "C:\data\inventory.dat (The system cannot find the path specified)".

How am I to create able a folder that currently does not exist? I'm reading the java.sun website on the File class, the mkdirs methods, and the FileSystemView class; however, I'm having trouble implementing the requirements in my code (I wish API documentation was more understandable to me.). Can an example be provided? Thank you everyone.






[ November 18, 2007: Message edited by: Xavier Downing ]
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How am I to create able a folder that currently does not exist? I'm reading the java.sun website on the File class, the mkdirs methods, and the FileSystemView class; however, I'm having trouble implementing the requirements in my code (I wish API documentation was more understandable to me.). Can an example be provided? Thank you everyone.


What is the "trouble" that you had with the mkdirs() method? it seems pretty straightforward to me.

Anyway, here is an example with the mkdirs() method. I put in some sanity checks too, to give you an example of other methods of the File class.



Henry
 
Xavier Downing
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! It's just that I'm such a dummy with creating codes from reading the API. When you read the API about the mkdirs, it doesn't tell you about using if and else statements to accomplish the task required. Usually, I read my textbook, or other reading materials (e.g. Java for Dummies) to help me out; however, none of the material touches on creating directories. When I take a look at the API, I'm like in the middle of an Ocean and can't swim. I wish I was able to read the API and formulate my code just off of that. I read the API and I'm like... so? What advice can you give me with regard to understanding the API well enough to create a code? Any code?
[ November 18, 2007: Message edited by: Xavier Downing ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!