| | |
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 |
2dgraphics account android api apple applet application array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class classes client code component data database derby design draw eclipse encryption error event exception fractal game givemetehcodez graphics gui html ide if_statement image inheritance input integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel jtextfield julia linux list loop map method methods midlethttpconnection mobile monitoring netbeans newbie nullpointerexception open-source oracle print printing problem program programming project property recursion reference ria scanner screen search server set size sms sort sourcelabs splash sql static stop string swing testautomation threads time tree ui unicode validation windows





