| | |
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!!!!
Views: 560 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for Java
add android api apple applet application arguments array arrays automation bank binary bluetooth chat chooser class classes client code component converter database digit draw eclipse equation error event exception file fractal functiontesting game givemetehcodez graphics gui health helpwithhomework html hyper ide idea image infinite input int integer j2me java javame javaprojects jmf jni jpanel julia linux list loop main map method methods mobile myregfun netbeans newbie nonstatic number object oracle pattern pearl print problem program programming project recursion scanner screen scrollbar server set size sms socket sort spamblocker sql sqlserver string superclass swing test thread threads time transfer tree windows






