Add Java snippets
This commit is contained in:
parent
504576a887
commit
c7e4baee7e
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
|
||||
/**
|
||||
* Read ASCII file for Java > 6
|
||||
*/
|
||||
private String readFile(String filePath) {
|
||||
String ret = "";
|
||||
try (BufferedReader buff = new BufferedReader(new FileReader(filePath))) {
|
||||
String line;
|
||||
while ((line = buff.readLine()) != null) {
|
||||
ret += line;
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(Plugin.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Plugin.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read ASCII file for Java <= 6
|
||||
*/
|
||||
private String readFile(String filePath) {
|
||||
String ret = "";
|
||||
try{
|
||||
BufferedReader buff = new BufferedReader(new FileReader(filePath));
|
||||
String line;
|
||||
while ((line = buff.readLine()) != null) {
|
||||
ret += line;
|
||||
}
|
||||
buff.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(Plugin.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Plugin.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
String OS = System.getProperty("os.name").toLowerCase();
|
||||
|
||||
public static boolean isWindows() {
|
||||
return (OS.indexOf("win") >= 0);
|
||||
}
|
||||
|
||||
public static boolean isMac() {
|
||||
return (OS.indexOf("mac") >= 0);
|
||||
}
|
||||
|
||||
public static boolean isUnix() {
|
||||
return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 );
|
||||
}
|
||||
Loading…
Reference in New Issue