wood burning stoves 2.0*
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
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: 41101
    
  45
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 - my free Android networking tools app
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

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: 41101
    
  45
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
What are these: .javaFileName.java.swp ?
Problem in opening a file in mac
Assignment 1.1
how to get unix machine name and find if a specified file exist ?
Out;put is not getting in this Shell Script??