List of usage examples for java.lang System getProperties
public static Properties getProperties()
From source file:List.java
public static void main(String args[]) throws Exception { Properties p = System.getProperties(); p.list(System.out);//from w ww.ja v a2 s . c o m FileOutputStream fos = new FileOutputStream("sys.out"); p.store(fos, null); fos.close(); Map map = new TreeMap(p); System.out.println(map); }
From source file:DumpProps.java
public static void main(String args[]) { Properties props = System.getProperties(); Iterator iter = props.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); System.out.println(entry.getKey() + " --- " + entry.getValue()); }//from www. j a v a 2 s .c o m System.out.println("-------"); Enumeration e = props.propertyNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); System.out.println(key + " --- " + props.getProperty(key)); } }
From source file:Main.java
public static void main(String s[]) throws Exception { try {//from w w w .jav a 2s .co m Properties systemSettings = System.getProperties(); systemSettings.put("proxySet", "true"); systemSettings.put("http.proxyHost", "proxy.mycompany.local"); systemSettings.put("http.proxyPort", "80"); URL u = new URL("http://www.java.com"); HttpURLConnection con = (HttpURLConnection) u.openConnection(); sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder(); String encodedUserPwd = encoder.encode("domain\\username:password".getBytes()); con.setRequestProperty("Proxy-Authorization", "Basic " + encodedUserPwd); con.setRequestMethod("HEAD"); System.out.println(con.getResponseCode() + " : " + con.getResponseMessage()); System.out.println(con.getResponseCode() == HttpURLConnection.HTTP_OK); } catch (Exception e) { e.printStackTrace(); System.out.println(false); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { Properties systemSettings = System.getProperties(); systemSettings.put("proxySet", "true"); systemSettings.put("http.proxyHost", "proxy.mycompany.local"); systemSettings.put("http.proxyPort", "80"); URL u = new URL("http://www.google.com"); HttpURLConnection con = (HttpURLConnection) u.openConnection(); BASE64Encoder encoder = new BASE64Encoder(); String encodedUserPwd = encoder.encode("domain\\username:password".getBytes()); con.setRequestProperty("Proxy-Authorization", "Basic " + encodedUserPwd); con.setRequestMethod("HEAD"); System.out.println(con.getResponseCode() + " : " + con.getResponseMessage()); System.out.println(con.getResponseCode() == HttpURLConnection.HTTP_OK); }
From source file:Main.java
public static void main(String[] argv) throws Exception { byte[] b = new byte[1]; Properties systemSettings = System.getProperties(); systemSettings.put("http.proxyHost", "proxy.mydomain.local"); systemSettings.put("http.proxyPort", "80"); URL u = new URL("http://www.google.com"); HttpURLConnection con = (HttpURLConnection) u.openConnection(); BASE64Encoder encoder = new BASE64Encoder(); String encodedUserPwd = encoder.encode("mydomain\\MYUSER:MYPASSWORD".getBytes()); con.setRequestProperty("Proxy-Authorization", "Basic " + encodedUserPwd); DataInputStream di = new DataInputStream(con.getInputStream()); while (-1 != di.read(b, 0, 1)) { System.out.print(new String(b)); }/* w w w . j a v a2s .c o m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { byte[] b = new byte[1]; Properties systemSettings = System.getProperties(); systemSettings.put("http.proxyHost", "proxy.mydomain.local"); systemSettings.put("http.proxyPort", "80"); Authenticator.setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("mydomain\\username", "password".toCharArray()); }//from w w w . j a v a2s . c o m }); URL u = new URL("http://www.google.com"); HttpURLConnection con = (HttpURLConnection) u.openConnection(); DataInputStream di = new DataInputStream(con.getInputStream()); while (-1 != di.read(b, 0, 1)) { System.out.print(new String(b)); } }
From source file:MainClass.java
public static void main(String argv[]) throws Exception { Properties props = System.getProperties(); props.put("javax.xml.transform.TransformerFactory", "org.apache.xalan.xsltc.trax.TransformerFactoryImpl"); System.setProperties(props);// w w w . j a va 2 s . c o m TransformerFactory tFactory = TransformerFactory.newInstance(); Templates translet = tFactory.newTemplates(new StreamSource("OrderProcessing.xslt")); Transformer transformer = translet.newTransformer(); transformer.transform(new StreamSource("CustomerOrders.xml"), new StreamResult(new FileOutputStream("SortedOrders.html"))); transformer.transform(new StreamSource("CustomerOrders1.xml"), new StreamResult(new FileOutputStream("SortedOrders1.html"))); }
From source file:TreeEditJCheckBox.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Properties props = System.getProperties(); JTree tree = new JTree(props); JCheckBox checkBox = new JCheckBox("To be or not to be"); TreeCellEditor editor = new DefaultCellEditor(checkBox); tree.setEditable(true);/*from www.j a va 2 s.com*/ tree.setCellEditor(editor); JScrollPane scrollPane = new JScrollPane(tree); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("ArrayListComboBoxModel"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Collection<Object> col = System.getProperties().values(); ArrayList<Object> arrayList = new ArrayList<Object>(col); ArrayListComboBoxModel model = new ArrayListComboBoxModel(arrayList); JComboBox comboBox = new JComboBox(model); frame.add(comboBox, BorderLayout.NORTH); frame.setSize(300, 225);//from w w w. ja v a 2 s . com frame.setVisible(true); }
From source file:TreeEditJTextField.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Properties props = System.getProperties(); JTree tree = new JTree(props); JTextField textField = new JTextField(); TreeCellEditor editor = new DefaultCellEditor(textField); tree.setEditable(true);/*from ww w . j a v a 2s .c o m*/ tree.setCellEditor(editor); JScrollPane scrollPane = new JScrollPane(tree); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }