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:HyperlinkTest.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); final JEditorPane ep = new JEditorPane(); try {/*from w ww . j a v a2 s.co m*/ ep.setPage("http://www.java2s.com"); } catch (IOException e) { System.err.println("Bad URL: " + e); System.exit(-1); } HyperlinkListener listener = new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { ep.setPage(e.getURL()); } catch (IOException ioe) { System.err.println("Error loading: " + ioe); } } } }; ep.addHyperlinkListener(listener); ep.setEditable(false); JScrollPane pane = new JScrollPane(ep); contentPane.add(pane, BorderLayout.CENTER); frame.setSize(640, 480); frame.show(); }
From source file:GetURLParts.java
public static void main(String args[]) { try {/* ww w. j a v a 2 s.c om*/ URL u = new URL("http://www.java2s.com"); System.out.println("The URL is " + u); System.out.println("The protocol part is " + u.getProtocol()); System.out.println("The host part is " + u.getHost()); System.out.println("The port part is " + u.getPort()); System.out.println("The file part is " + u.getFile()); System.out.println("The ref part is " + u.getRef()); } // end try catch (MalformedURLException e) { System.err.println("not a URL I understand."); } }
From source file:Main.java
public static void main(String[] args) { Path path = Paths.get("C:/tutorial/Java/JavaFX", "Topic.txt"); try {/* w w w. j a va 2s . c om*/ BasicFileAttributeView bv = Files.getFileAttributeView(path, BasicFileAttributeView.class); BasicFileAttributes ba = bv.readAttributes(); System.out.println(ba.creationTime()); } catch (IOException e) { System.err.println(e); } }
From source file:MetalModExample.java
public static void main(String[] args) { try {//from w w w . j a v a 2s. c o m UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception e) { System.err.println("Metal is not available on this platform?!"); System.exit(1); } JComponent before = makeExamplePane(); UIManager.put("ScrollBarUI", "MyMetalScrollBarUI"); JComponent after = makeExamplePane(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = f.getContentPane(); c.setLayout(new GridLayout(2, 1, 0, 1)); c.add(before); c.add(after); f.setSize(450, 400); f.setVisible(true); }
From source file:PDFMetaTitle.java
public static void main(String[] args) { Document document = new Document(); try {/*ww w. ja va 2 s . co m*/ PdfWriter.getInstance(document, new FileOutputStream("PDFMetaTitle.pdf")); document.addTitle("Hello World example"); document.open(); document.add(new Paragraph("Hello World")); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:Main.java
public static void main(String[] args) { Path wiki_path = Paths.get("C:/tutorial/wiki", "wiki.txt"); Charset charset = Charset.forName("UTF-8"); String text = "\nfrom java2s.com!"; try (BufferedWriter writer = Files.newBufferedWriter(wiki_path, charset, StandardOpenOption.APPEND)) { writer.write(text);/*from w ww.ja va 2 s . c o m*/ } catch (IOException e) { System.err.println(e); } }
From source file:Main.java
public static void main(String[] args) { Path copy_from_2 = Paths.get("C:/tutorial/Java/JavaFX", "tutor.txt"); Path copy_to_2 = Paths.get("C:/tutorial/Java/Swing", "tutor.txt"); try (InputStream is = new FileInputStream(copy_from_2.toFile())) { Files.copy(is, copy_to_2, REPLACE_EXISTING); } catch (IOException e) { System.err.println(e); }//from w w w .ja v a 2 s . co m }
From source file:X.java
public static void main(String[] args) { try {//from w ww. ja va2 s.co m Class<?> clazz = Class.forName("X"); X x = (X) clazz.newInstance(); Class[] argTypes = { String.class }; Method method = clazz.getMethod("objectMethod", argTypes); System.out.println(method.getDefaultValue()); } catch (Exception e) { System.err.println(e); } }
From source file:Main.java
public static void main(String[] args) { Path wiki_path = Paths.get("C:/tutorial/wiki", "wiki.txt"); Charset charset = Charset.forName("UTF-8"); try (BufferedReader reader = Files.newBufferedReader(wiki_path, charset)) { String line = null;// w w w. java 2 s . c o m while ((line = reader.readLine()) != null) { System.out.println(line); } } catch (IOException e) { System.err.println(e); } }
From source file:getSocketInfo.java
public static void main(String[] args) { for (int i = 0; i < args.length; i++) { try {//from w ww . jav a2s .c o m Socket theSocket = new Socket(args[i], 80); System.out.println("Connected to " + theSocket.getInetAddress() + " on port " + theSocket.getPort() + " from port " + theSocket.getLocalPort() + " of " + theSocket.getLocalAddress()); } // end try catch (UnknownHostException e) { System.err.println("I can't find " + args[i]); } catch (SocketException e) { System.err.println("Could not connect to " + args[i]); } catch (IOException e) { System.err.println(e); } } }