Re: IO: creating dirs/files...
- From: Eric Sosman <esosman@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 31 Aug 2007 12:00:41 -0400
maya wrote:
at work I build rather large websites from scratch...
I figured, just for the hell of it, why not write a java class that creates the dirs and the files that go inside the dirs??? (this would be locally, I develop in Weblogic localhost..) so am talking about a stand-alone class...
first thing I notice in API (1.4) is that mkdir() method doesn't take any params, how do you tell it what to name the dir??
File folder = new File(directoryName);
folder.mkdir();
IMHO, it's unfortunate that Sun chose the name "File"
for this class. It's really not a representation of what
we think of as a file in the file system, but of a name
that might be used to denote a file, and the discrepancy
leads to confusion.
`new File(directoryName)' doesn't "create a file" in
the file system; it just "creates a File object" in your
program, a File object that holds a name that might (or
might not) be the name of an actual file. Then the mkdir()
method tries to create an actual directory using that name.
Other methods can create ordinary data files, delete files
or directories, list the contents of directories, and so on.
But File itself is really just a holder for a name.
--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxxx
.
- References:
- IO: creating dirs/files...
- From: maya
- IO: creating dirs/files...
- Prev by Date: IO: creating dirs/files...
- Next by Date: Re: swing comments from an ex-C++ motif programmer
- Previous by thread: IO: creating dirs/files...
- Next by thread: Re: IO: creating dirs/files...
- Index(es):
Relevant Pages
|