I know this is a trite question but I still can't find the answer. I'm doing a program that has to get the free disk space of a certain folder. The program has to be compatible with java 1.5 so I can't use getFreeSpace() method. So for this purpose I use:
It works fine but when the folder that has to be checked has intervals in the path ( e.g /mnt/test dir/) the command doesn't execute properly and when it tries to get the output from it the program breaks since nothing was output by the end.
I tried to parse the path of the folder by putting '\' before every interval but no luck either. It doesn't work with quotations. What is wrong with that exec() method?
Any suggestions or advises would be appreciated.
Placing spaces in file/directory names is a horrible thing to do. Even Microsoft has finally wised up. I don't know about Apple.
The reason why it's horrible is because it confuses command-line parsers (and occasionally people, as well). On the original Macintosh, there was no command line to speak of, so they could get away from it, but most of the rest of the world is less GUI-oriented, so as a general rule, if you're given any choice in the matter, don't put spaces in paths.
You can escape spaces in Unix pathnames, using a backslash, but since the backslash is itself magic to Java, you have to double it up, as in "test\\ dir".
Customer surveys are for companies who didn't pay proper attention to begin with.