creating directories

M

Marcelo

Hello,

I would like to know if it is possible to create directories from JAVA
without using the Process class (neither the Runtime class).

I would like just to create some directories automaticly
(platform-independent)

thank you very much,

Marcelo
 
M

Marcelo

Benji said:
create a new File object with the name of the directory you want to create,
and call mkdir() on it.
Do you mean

File file = new File("mkdir() whatever/here.txt");

seems a little bit strange...

MArcelo
 
C

Chris Smith

Marcelo said:
Do you mean

File file = new File("mkdir() whatever/here.txt");

No, that's not what Benji meant. You appear to be struggling with the
very basics of the Java programming language. If so, it would be wise
to back off and spend more time getting familiar with objects and
methods before worrying about learning APIs.

What Benji meant was:

new File(pathName).mkdir();

Where pathName is a String variable containing the path of the directory
you want to create.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
J

Jeffrey Schwab

Marcelo said:
Do you mean

File file = new File("mkdir() whatever/here.txt");

seems a little bit strange...

MArcelo


import java.io.File;
import java.io.PrintWriter;

public class Mkdir {
static PrintWriter err = new PrintWriter(System.err, true);

public static void main(String[] args) {
if (args.length != 1) {
err.println("usage: java Mkdir <dirname>");
System.exit(1);
}

new File(args[0]).mkdir();
}
}
 
M

Marcelo

Jeffrey said:
Marcelo said:
Do you mean

File file = new File("mkdir() whatever/here.txt");

seems a little bit strange...

MArcelo



import java.io.File;
import java.io.PrintWriter;

public class Mkdir {
static PrintWriter err = new PrintWriter(System.err, true);

public static void main(String[] args) {
if (args.length != 1) {
err.println("usage: java Mkdir <dirname>");
System.exit(1);
}

new File(args[0]).mkdir();
}
}
thanks alot

Marcelo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top