List of usage examples for java.lang System err
PrintStream err
To view the source code for java.lang System err.
Click Source Link
From source file:ListAllCookies.java
public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("usage: java ListAllCookies url"); return;/* w ww . ja v a 2s .co m*/ } CookieManager cm = new CookieManager(); cm.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cm); new URL(args[0]).openConnection().getContent(); List<HttpCookie> cookies = cm.getCookieStore().getCookies(); for (HttpCookie cookie : cookies) { System.out.println("Name = " + cookie.getName()); System.out.println("Value = " + cookie.getValue()); System.out.println("Lifetime (seconds) = " + cookie.getMaxAge()); System.out.println("Path = " + cookie.getPath()); System.out.println(); } }
From source file:GetMessageExample.java
public static void main(String args[]) throws Exception { if (args.length != 3) { System.err.println("Usage: java MailExample host username password"); System.exit(-1);// www.j ava2 s.com } String host = args[0]; String username = args[1]; String password = args[2]; // Create empty properties Properties props = new Properties(); // Get session Session session = Session.getDefaultInstance(props, null); // Get the store Store store = session.getStore("pop3"); store.connect(host, username, password); // Get folder Folder folder = store.getFolder("INBOX"); folder.open(Folder.READ_ONLY); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); // Get directory Message message[] = folder.getMessages(); for (int i = 0, n = message.length; i < n; i++) { System.out.println(i + ": " + message[i].getFrom()[0] + "\t" + message[i].getSubject()); System.out.println("Read message? [YES to read/QUIT to end]"); String line = reader.readLine(); if ("YES".equalsIgnoreCase(line)) { System.out.println(message[i].getContent()); } else if ("QUIT".equalsIgnoreCase(line)) { break; } } // Close connection folder.close(false); store.close(); }
From source file:FuncEvaluator.java
public static void main(String[] args) { if (args.length != 2) { System.err .println("usage: java FuncEvaluator scriptfile " + "script-exp"); return;/*from w w w . j a va 2s . c o m*/ } ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("rhino"); try { System.out.println(engine.eval(new FileReader(args[0]))); System.out.println(engine.eval(args[1])); } catch (ScriptException se) { System.err.println(se.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } }
From source file:HttpClientPreferences.java
public static void main(String args[]) throws Exception { HttpClient client = new HttpClient(); System.err.println( "The User Agent before changing it is: " + client.getParams().getParameter("http.useragent")); client.getParams().setParameter("http.useragent", "Browser at Client level"); System.err.println("Client's User Agent is: " + client.getParams().getParameter("http.useragent")); GetMethod method = new GetMethod("http://www.google.com"); method.getParams().setParameter("http.useragent", "Browser at Method level"); try {/*from w w w.j a v a2 s . c om*/ client.executeMethod(method); } catch (Exception e) { System.err.println(e); } finally { method.releaseConnection(); } System.err.println("Method's User Agent is: " + method.getParams().getParameter("http.useragent")); }
From source file:MainClass.java
public static void main(String[] args) { try {/* w w w .jav a2s . com*/ copy(System.in, System.out); } catch (IOException ex) { System.err.println(ex); } }
From source file:Redirect.java
public static void main(String args[]) throws Exception { PrintStream origOut = System.out; PrintStream origErr = System.err; InputStream stdin = null;// w w w . jav a 2 s.c o m stdin = new FileInputStream("Redirect.in"); PrintStream stdout = null; stdout = new PrintStream(new FileOutputStream("Redirect.out")); PrintStream stderr = null; stderr = new PrintStream(new FileOutputStream("Redirect.err")); origOut.println("1"); System.out.println("2"); origOut.println("3"); System.err.println("4"); origErr.println("5"); System.setIn(stdin); System.setOut(stdout); System.setErr(stderr); origOut.println("\nR"); System.out.println("T"); origOut.println("Tq"); System.err.println("Tqw"); origErr.println("Test"); origOut.println("\nRedirect: Round #3"); int inChar = 0; while (-1 != inChar) { try { inChar = System.in.read(); } catch (Exception e) { // Clean up the output and bail. origOut.print("\n"); break; } origOut.write(inChar); } stdin.close(); stdout.close(); stderr.close(); System.exit(0); }
From source file:Main.java
public static void main(String[] args) { try {//from ww w . j a v a 2 s . c o m while (true) { int datum = System.in.read(); if (datum == -1) break; System.out.println(datum); } } catch (IOException ex) { System.err.println("Couldn't read from System.in!"); } }
From source file:MainClass.java
public static void main(String[] a) { FileOutputStream outputFile = null; // Place to store the stream reference try {//from w ww . ja va 2 s.com outputFile = new FileOutputStream("myFile.txt"); } catch (FileNotFoundException e) { e.printStackTrace(System.err); } }
From source file:HttpClientTest.java
public static void main(String args[]) throws Exception { HttpClient client = new HttpClient(); GetMethod method = new GetMethod("http://www.google.com"); int returnCode = client.executeMethod(method); System.err.println(method.getResponseBodyAsString()); method.releaseConnection();/* w ww .j a v a 2 s .c o m*/ }
From source file:Main.java
public static void main(String[] args) { try {/*from w w w.ja va2 s .c o m*/ DTD d1 = DTD.getDTD("html"); for (int i = 0; i < 14; i++) { System.out.println(d1.getElement(i).getName()); } } catch (IOException e) { System.err.println(e); e.printStackTrace(); } }