File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Creating folers anf files in Unix using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Creating folers anf files in Unix using java" Watch "Creating folers anf files in Unix using java" New topic
Author

Creating folers anf files in Unix using java

sivakumar damodaran
Greenhorn

Joined: Jul 30, 2008
Posts: 2
I'm trying to create folders and files in UNIX. The problem is the folder name and file name has space in it, but UNIX doesn't allow to space in them. Is there a way to do it?


Regards,<br />Sivakumar,<br />PLM System Analyst
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39535
    
  27
Welcome to JavaRanch.
but UNIX doesn't allow to space in them.

I've no problem creating a directory containing a space, either using File.mkdir or on the command line. How are you trying to do that?


Ping & DNS - updated with new look and Ping home screen widget
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19538
    
  16

Unix allows just about anything in file / folder names, including spaces and even other characters usually used by the shell. I even managed to create files that start with a -; it's a real trick trying to delete those I tell you, since rm thinks it's a flag for it.

The trick is, on the shell you need to either encapsulate the file name in double quotes "", or use \ as an escape character. So listing all files in folder "My Folder" could be done as follows:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
sivakumar damodaran
Greenhorn

Joined: Jul 30, 2008
Posts: 2
I tried all these but nothing works
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39535
    
  27
What happened when you tried to do this on the command line?

What happened when you tried to do this in Java code?

TellTheDetails
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating folers anf files in Unix using java
 
Similar Threads
Assignment 1.1
Out;put is not getting in this Shell Script??
Problem in opening a file in mac
how to get unix machine name and find if a specified file exist ?
What are these: .javaFileName.java.swp ?