Question:
Is this a bug in Java? do i need to report it to Oracle?
2011-02-01 09:51:08 UTC
I want to do this:

pr = rt.exec("cp " + directoryName + "/"+ files[i] + " ./"+ fileName+"/"+files[i]);
System.out.println("cp " + directoryName + "/"+ files[i] + " ./"+ fileName+"/"+files[i]);

but i want the file name be in quotes because my file names and directories have blank spaces in them

however using "\"" for quotes prints a line ok (!!!) but does NOT work in Java.


is this a Java bug?

WHen i take the printed line from java and run it in terminal, it then executes OK (files are copied)!

but from Java that line is not copying the files.
Three answers:
Andrew S
2011-02-01 10:09:53 UTC
No. The string assembly process is independent of the function the result is passed to. In this instance I suspect the CWD is not what you think it is or you are running in a sandbox. Without much more context it is impossible say. Try with something simpler, e.g. an rt.exec("touch foo") and see if the empty file foo is created.



Secondly, questioning the development system is a quick way to deter a lot of experienced coders who could help from helping you. Always begin from the premise that bugs are in your code or your understanding. Bugs in developer tools do exist but they are much, much rarer and this would be a particularly unusual one since it would imply a deep coupling between the parser and two completely separate parts of the language.
2011-02-01 17:54:56 UTC
I'm not exactly sure what you're doing, but this doesn't look like a Java bug at all. More likely a bug with your code.
jayteemoney
2011-02-01 22:41:12 UTC
are you trying to hack?


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...