List of usage examples for java.lang System getProperty
public static String getProperty(String key)
From source file:Main.java
public static void main(String[] args) throws Exception { File file = new File("user.txt"); FileWriter writer = new FileWriter(file, true); writer.write("username=java;password=secret" + System.getProperty("line.separator")); writer.flush();//from w ww . ja va 2 s.co m writer.close(); }
From source file:Main.java
public static void main(String[] args) { String destFile = "luci2.txt"; // Get the line separator for the current platform String lineSeparator = System.getProperty("line.separator"); String line1 = "test"; String line2 = "test1"; String line3 = "test2"; String line4 = "test3"; try (FileOutputStream fos = new FileOutputStream(destFile)) { fos.write(line1.getBytes());//from w w w . ja v a 2s . com fos.write(lineSeparator.getBytes()); fos.write(line2.getBytes()); fos.write(lineSeparator.getBytes()); fos.write(line3.getBytes()); fos.write(lineSeparator.getBytes()); fos.write(line4.getBytes()); // Flush the written bytes to the file fos.flush(); System.out.println("Text has been written to " + (new File(destFile)).getAbsolutePath()); } catch (Exception e2) { e2.printStackTrace(); } }
From source file:MyClass.java
public static void main(String[] argv) throws Exception { URL[] urls = null;/*w w w .j a v a 2 s. c o m*/ File dir = new File(System.getProperty("user.dir") + File.separator + "dir" + File.separator); URL url = dir.toURI().toURL(); urls = new URL[] { url }; ClassLoader cl = new URLClassLoader(urls); Class cls = cl.loadClass("MyClass"); MyClass myObj = (MyClass) cls.newInstance(); }
From source file:KVMProperties.java
public static void main(String[] args) { for (int i = 0; i < properties.length; i++) { System.out.println(properties[i] + " = " + System.getProperty(properties[i])); }/*from w w w. j ava 2s. co m*/ }
From source file:Test.java
License:asdf
public static void main(String[] args) throws IOException { Path path = Paths.get("/users.txt"); final String newLine = System.getProperty("line.separator"); try (SeekableByteChannel sbc = Files.newByteChannel(path, StandardOpenOption.APPEND)) { String output = newLine + "asdf" + newLine; ByteBuffer buffer = ByteBuffer.wrap(output.getBytes()); sbc.write(buffer);//from w w w . jav a 2s. c om } }
From source file:Main.java
public static void main(String[] args) { Path basedir = FileSystems.getDefault().getPath("C:/tutorial/tmp/"); String tmp_dir_prefix = "Swing_"; //get the default temporary folders path String default_tmp = System.getProperty("java.io.tmpdir"); System.out.println(default_tmp); try {//from w w w . j a v a 2 s .c om //set a prefix Path tmp_2 = Files.createTempDirectory(tmp_dir_prefix); System.out.println("TMP: " + tmp_2.toString()); } catch (IOException e) { System.err.println(e); } }
From source file:Test.java
License:asdf
public static void main(String[] args) throws IOException { Path path = Paths.get("/users.txt"); final String newLine = System.getProperty("line.separator"); try (SeekableByteChannel sbc = Files.newByteChannel(path, StandardOpenOption.WRITE)) { ByteBuffer buffer;/*from ww w . ja va2s .c o m*/ long position = sbc.size(); sbc.position(position); System.out.println("Position: " + sbc.position()); buffer = ByteBuffer.wrap((newLine + "asdf").getBytes()); sbc.write(buffer); System.out.println("Position: " + sbc.position()); buffer = ByteBuffer.wrap((newLine + "asdf").getBytes()); sbc.write(buffer); System.out.println("Position: " + sbc.position()); } }
From source file:GetIt.java
public static void main(String args[]) throws Exception { JMenu it = new JMenu(); String classID = it.getUIClassID(); System.out.println(classID);//w ww .j ava 2s . c om String className = (String) UIManager.get(classID); System.out.println(className); Class.forName(className); System.out.println(System.getProperty("swing.defaultlaf")); System.out.println(System.getProperty("swing.auxiliarylaf")); System.out.println(System.getProperty("swing.plaf.multiplexinglaf")); System.out.println(System.getProperty("swing.installedlafs")); }
From source file:Main.java
public static void main(String[] args) { Path basedir = FileSystems.getDefault().getPath("C:/tutorial/tmp"); String tmp_file_prefix = "Swing_"; String tmp_file_sufix = ".txt"; //get the default temporary folders path String default_tmp = System.getProperty("java.io.tmpdir"); System.out.println(default_tmp); try {/* w w w .j a v a 2 s .com*/ //create a tmp file in a the base dir Path tmp_3 = Files.createTempFile(basedir, tmp_file_prefix, tmp_file_sufix); System.out.println("TMP: " + tmp_3.toString()); } catch (IOException e) { System.err.println(e); } }
From source file:Main.java
public static void main(String[] args) { Path basedir = FileSystems.getDefault().getPath("C:/tutorial/tmp"); String tmp_file_prefix = "Swing_"; String tmp_file_sufix = ".txt"; //get the default temporary folders path String default_tmp = System.getProperty("java.io.tmpdir"); System.out.println(default_tmp); try {/* w ww . j a v a 2s.c o m*/ //set a prefix and a sufix Path tmp_2 = Files.createTempFile(tmp_file_prefix, tmp_file_sufix); System.out.println("TMP: " + tmp_2.toString()); } catch (IOException e) { System.err.println(e); } }