This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating folers anf files in Unix using java

 
sivakumar damodaran
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
sivakumar damodaran
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried all these but nothing works
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tried to do this on the command line?

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

TellTheDetails
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic