
Untitled
By: a guest on
Apr 28th, 2012 | syntax:
None | size: 0.70 KB | hits: 11 | expires: Never
Java Cross-Platfrom OS detection to declare file path location
public class FileConfiguration {
private String checkOs() {
String path = "";
if (System.getProperty("os.name").startsWith("Windows")) {
// includes: Windows 2000, Windows 95, Windows 98, Windows NT, Windows Vista, Windows XP
path = "C://Users//...";
}
elseif (System.getProperty("os.name").startsWith("Mac")) {
path = "///Users//...";
}
return path;
}
// declare paths for file source and destination
String destinationPath = path;
String sourcePath = path;
if (a) {
// code
} else if (b) {
// code
}