Re: help with properties class



On Feb 28, 8:01 pm, "Andrew Thompson" <andrewtho...@xxxxxxxxx> wrote:
On Feb 28, 6:17 pm, divyatiwari...@xxxxxxxxx wrote:
...
p.setProperties("path,C:\Program Files\Java\jdk1.6.0\bin");
...
Note that when it comes to paths, using
hard coded file separator characters
(the '\') causes cross-platform problems.

A better way to express that might be..

<sscce>
import java.io.File;

class JavaHome {

public static void main(String[] args) {
String sJavaHome = System.getProperty("java.home");
File fJavaHome = new File(sJavaHome);
// use the x-plat way to get a file separator.
File fJavaBin = new File( fJavaHome, "bin" );

// the 'toString()' is not strictly needed
System.out.println( fJavaBin.toString() +
" \texists: " + fJavaBin.exists() );
}
}
</sscce>

HTH

Andrew T.

.