giving file path in unix and windows
hi,
i'm having problem with reading file from both windows and unix as now i give
if (os == win)
file="mydir\\mydir1\\myfile"
else
file="mydir/mydir1/myfile"
wherei get mydir* from environment.
and then open that file.
but i feel the above is clumsy and is more like C #ifdef
Can you please help me out on this.
Thanks & Regards
Rajkumar
Two possibilities:String filename = "mydir" + File.separatorChar + "mydir1" + File.separatorChar + "myfile";File mydir = new File("mydir");File mydir1 = new File(mydir, "mydir1");File myfile = new File(mydir1, "myfile");
hi,
use the System property "file.separator" to figure out the seperator.
for eg
java.util.Properties prop = System.getProperties();
String separator = prop.getProperty("file.separator");
System.out.println("separator :" + separator);
hope that helpz
cheerz
ynkrish