Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 0.70 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Java Cross-Platfrom OS detection to declare file path location
  2. public class FileConfiguration {
  3.  
  4.     private String checkOs() {
  5.         String path = "";        
  6.         if (System.getProperty("os.name").startsWith("Windows")) {
  7.             // includes: Windows 2000,  Windows 95, Windows 98, Windows NT, Windows Vista, Windows XP
  8.             path = "C://Users//...";            
  9.  
  10.         }
  11.         elseif (System.getProperty("os.name").startsWith("Mac")) {
  12.             path = "///Users//...";
  13.         }
  14.         return path;        
  15.  
  16.     }
  17.  
  18.     // declare paths for file source and destination
  19.     String destinationPath = path;
  20.     String sourcePath = path;
  21.        
  22. if (a) {
  23. // code
  24. } else if (b) {
  25. // code
  26. }