| | |
Path names with spaces.
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2007
Posts: 60
Reputation:
Solved Threads: 0
Hi.
I am writing a mac program that among other things, allows a user to create unix links to files. Now I am using the runtime.exec() method to run the ls -s command e.g.
ls -s dir1/fileName dir2/NewfileName
This works but becomes difficult if the path name to the file has a space. e.g.
ls -s dir 1/fileName dir2/NewfileName
I thought of moving the file to a central temporary directory then making the unix link then moving them back but in Java there is no real way of moving a file rather it is copying and the unix command mv is also at the mercy of paths with spaces.
Are there any suggestions to overcome this?
Many thanks
I am writing a mac program that among other things, allows a user to create unix links to files. Now I am using the runtime.exec() method to run the ls -s command e.g.
ls -s dir1/fileName dir2/NewfileName
This works but becomes difficult if the path name to the file has a space. e.g.
ls -s dir 1/fileName dir2/NewfileName
I thought of moving the file to a central temporary directory then making the unix link then moving them back but in Java there is no real way of moving a file rather it is copying and the unix command mv is also at the mercy of paths with spaces.
Are there any suggestions to overcome this?
Many thanks
•
•
Join Date: Oct 2007
Posts: 60
Reputation:
Solved Threads: 0
Hi,
I was haste in marking as solved.
The idea of enclosing the respective paths in double quotes works when doing directly into the terminal, but from a java program using the
process.exec(command)
I have used single quotes '"' in the program to enclose the path name with the space in double quotes e.g. '"' + pathWithSpace + '"'; the result of which produces the following:
;)
Any further help or suggestions would be most welcome.
I was haste in marking as solved.
The idea of enclosing the respective paths in double quotes works when doing directly into the terminal, but from a java program using the
process.exec(command)
I have used single quotes '"' in the program to enclose the path name with the space in double quotes e.g. '"' + pathWithSpace + '"'; the result of which produces the following:
Any further help or suggestions would be most welcome.
![]() |
Similar Threads
- Forms Authorization/ Authentication using asp .net and vb .net (ASP.NET)
- Open In New Window Php (PHP)
- Wrong Directory (Legacy and Other Languages)
- modify script (Perl)
- Inputting text file data into an array, please help! (C++)
- This Should be Easy for You Guys! (Linux Servers and Apache)
- getting around spaces in windows command prompt commands (Windows NT / 2000 / XP)
- I've got Trojan.Holax... is this bad? (Viruses, Spyware and other Nasties)
- not-a-virusadware (Viruses, Spyware and other Nasties)
- This ought to be simple - extra spaces (PHP)
Other Threads in the Java Forum
- Previous Thread: damned variable vs. instantiated Object
- Next Thread: coding help please!!!!
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary bluetooth character chat class classes client code component consumer csv database desktop draw eclipse error event exception fractal ftp game givemetehcodez graphics gui html ide image input integer j2me japplet java javaarraylist javaee javaprojects jmf jni jpanel julia linked linux list loop mac map method methods mobile netbeans newbie objects online oracle oriented panel print printf problem program programming project projects properties recursion replaydirector reporting researchinmotion robot rotatetext rsa scanner screen se server set size sms sort sql string swing template test threads time tree ubuntu windows working





