List of usage examples for java.lang System getProperty
public static String getProperty(String key)
From source file:Main.java
/** * Checks if host operational system matches given operational system name. * @param osName the operational system name * @return <b><i>true</b></i> if host operational system matches given name, <b><i>false</b></i> otherwise. *///www . j av a2s .c om private static boolean checkHostOS(String osName) { return System.getProperty("os.name").toLowerCase().contains(osName); }
From source file:Main.java
public static String getHost() { return System.getProperty("smb.host"); }
From source file:Main.java
public static String getUsername() { return System.getProperty("smb.user"); }
From source file:Main.java
public static String getPassword() { return System.getProperty("smb.password"); }
From source file:Main.java
public static String readFile(String filename) { StringBuilder buf = new StringBuilder(); try {/*from w ww . j ava2 s. com*/ BufferedReader input = new BufferedReader(new FileReader(filename)); String line; while ((line = input.readLine()) != null) { buf.append(line); buf.append(System.getProperty("line.separator")); } } catch (IOException e) { e.printStackTrace(); } return buf.toString(); }
From source file:Main.java
public static String getCurrentProject() { try {// w w w . j av a 2 s. c o m String value = ""; Properties properties = new Properties(); FileInputStream inputFile = new FileInputStream(System.getProperty("user.dir") + "/system.properties"); properties.load(inputFile); inputFile.close(); if (properties.containsKey("ProjectPath")) { value = properties.getProperty("ProjectPath"); String resultName = new String(value.getBytes("ISO-8859-1"), "gbk"); return resultName; } else return value; } catch (FileNotFoundException e) { e.printStackTrace(); return ""; } catch (IOException e) { e.printStackTrace(); return ""; } catch (Exception ex) { ex.printStackTrace(); return ""; } }
From source file:Main.java
public static String readFile(File file) throws IOException { BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null;/*from w w w . j a v a 2 s.c o m*/ StringBuilder stringBuilder = new StringBuilder(); String ls = System.getProperty("line.separator"); while ((line = reader.readLine()) != null) { stringBuilder.append(line); stringBuilder.append(ls); } reader.close(); return stringBuilder.toString(); }
From source file:Main.java
/** * Gets the operating system type./*from w w w . j a va 2 s . c om*/ * * @return OS_WINDOWS, OS_MACINTOSH, or OS_OTHER */ public static int getOperatingSystem() { // Get the operating system name. String osName = ""; try { osName = System.getProperty("os.name"); } catch (Throwable t) { t.printStackTrace(); } // Convert to one of the operating system constants. int os = OS_OTHER; if (osName.toLowerCase().indexOf("windows") >= 0) { os = OS_WINDOWS; } else if (osName.startsWith("Mac OS X")) { os = OS_MACINTOSH; } return os; }
From source file:OSUtils.java
public static final boolean isSolaris() { return System.getProperty("os.name").equals("SunOS"); }
From source file:Main.java
public static synchronized DocumentBuilderFactory getDocumentBuilderFactory() { String oldDbfImpl = System.getProperty(DBF_SYSTEM_PROPERTY); System.setProperty(DBF_SYSTEM_PROPERTY, JAVA_INTERNAL_DBF_CLASS); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); if (oldDbfImpl != null) { System.setProperty(DBF_SYSTEM_PROPERTY, oldDbfImpl); } else {/*from w w w .j a va 2 s. co m*/ System.getProperties().remove(DBF_SYSTEM_PROPERTY); } return dbf; }