S
Shin
Hello there,
Here is the deal: spaces are allowed in file names; space is also used
to separate files on both win32 and *nix platform.
The following program won't run correctly on both win32 and *nix:
class PathName {
public static void main(String[] args) {
String javafile = args[0];
try {
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(new String[]{"javac", javafile}); //XXX
p.waitFor();
System.out.println( (p.exitValue() == 0)? "succeeded" :
"failed");
} catch (Exception e) {}
}
}
Consider file name with space in it, what should be passed to
Runtime.exec at XXX to make this code run both on win32 and *nix?
I tried putting quotation marks around the filename, replace space with
%20, neither seem to work perfectly.
Any tips?
-Shin
Here is the deal: spaces are allowed in file names; space is also used
to separate files on both win32 and *nix platform.
The following program won't run correctly on both win32 and *nix:
class PathName {
public static void main(String[] args) {
String javafile = args[0];
try {
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(new String[]{"javac", javafile}); //XXX
p.waitFor();
System.out.println( (p.exitValue() == 0)? "succeeded" :
"failed");
} catch (Exception e) {}
}
}
Consider file name with space in it, what should be passed to
Runtime.exec at XXX to make this code run both on win32 and *nix?
I tried putting quotation marks around the filename, replace space with
%20, neither seem to work perfectly.
Any tips?
-Shin