Example usage for java.lang System err

List of usage examples for java.lang System err

Introduction

In this page you can find the example usage for java.lang System err.

Prototype

PrintStream err

To view the source code for java.lang System err.

Click Source Link

Document

The "standard" error output stream.

Usage

From source file:ElementIteratorExample.java

public static void main(String args[]) throws Exception {

    if (args.length != 1) {
        System.err.println("Usage: java ElementIteratorExample input-URL");
    }//from  w  w  w  .j av a  2  s.  co m

    // Load HTML file synchronously
    URL url = new URL(args[0]);
    URLConnection connection = url.openConnection();
    InputStream is = connection.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);

    HTMLEditorKit htmlKit = new HTMLEditorKit();
    HTMLDocument htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument();
    HTMLEditorKit.Parser parser = new ParserDelegator();
    HTMLEditorKit.ParserCallback callback = htmlDoc.getReader(0);
    parser.parse(br, callback, true);

    // Parse
    ElementIterator iterator = new ElementIterator(htmlDoc);
    Element element;
    while ((element = iterator.next()) != null) {
        AttributeSet attributes = element.getAttributes();
        Object name = attributes.getAttribute(StyleConstants.NameAttribute);
        if ((name instanceof HTML.Tag)
                && ((name == HTML.Tag.H1) || (name == HTML.Tag.H2) || (name == HTML.Tag.H3))) {
            // Build up content text as it may be within multiple elements
            StringBuffer text = new StringBuffer();
            int count = element.getElementCount();
            for (int i = 0; i < count; i++) {
                Element child = element.getElement(i);
                AttributeSet childAttributes = child.getAttributes();
                if (childAttributes.getAttribute(StyleConstants.NameAttribute) == HTML.Tag.CONTENT) {
                    int startOffset = child.getStartOffset();
                    int endOffset = child.getEndOffset();
                    int length = endOffset - startOffset;
                    text.append(htmlDoc.getText(startOffset, length));
                }
            }
            System.out.println(name + ": " + text.toString());
        }
    }
    System.exit(0);
}

From source file:X.java

public static void main(String[] args) {
    try {/*  w  w w  .jav  a 2  s  .c o  m*/
        Class<?> clazz = Class.forName("X");
        X x = (X) clazz.newInstance();
        Class[] argTypes = { String.class };
        Method method = clazz.getMethod("objectMethod", argTypes);
        Type[] exp = method.getGenericExceptionTypes();
        for (Type anno : exp) {
            System.out.println(anno);
        }
        System.out.println();

    } catch (Exception e) {
        System.err.println(e);
    }
}

From source file:ExtraStyleUNDERLINEPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from   w  w w.  j a v a  2 s . c om*/
        PdfWriter.getInstance(document, new FileOutputStream("ExtraStyleUNDERLINEPDF.pdf"));
        document.open();

        document.add(new Chunk("underline",
                FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.UNDERLINE)));
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:MulticastSniffer.java

public static void main(String[] args) {
    InetAddress ia = null;/*from w  w  w . j  a  v  a 2  s  .c  om*/
    byte[] buffer = new byte[65535];
    DatagramPacket dp = new DatagramPacket(buffer, buffer.length);
    int port = 0;

    // read the address from the command line
    try {
        try {
            ia = InetAddress.getByName(args[0]);
        } catch (UnknownHostException e) {
            System.err.println(e);
        }
        port = Integer.parseInt(args[1]);
    } catch (Exception e) {
        System.err.println(e);
        System.err.println("Usage: java MulticastSniffer mcast-addr port");
        System.exit(1);
    }
    System.out.println("About to join " + ia);

    try {
        MulticastSocket ms = new MulticastSocket(port);
        ms.joinGroup(ia);
        while (true) {
            System.out.println("About to receive...");
            ms.receive(dp);
            String s = new String(dp.getData(), 0, 0, dp.getLength());
            System.out.println(s);
        }
    } catch (SocketException se) {
        System.err.println(se);
    } catch (IOException ie) {
        System.err.println(ie);
    }
}

From source file:AddingAWTImagePDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from w w w  .j  a  v a 2s  .c  o m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("AddingAWTImagePDF.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        java.awt.Image awtImage = Toolkit.getDefaultToolkit().createImage("logo.png");
        Image image = Image.getInstance(awtImage, null);
        image.setAbsolutePosition(100, 500);
        cb.addImage(image);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:MainClass.java

public static void main(String[] args) {

    for (int i = 0; i < args.length; i++) {
        if (args[i].toLowerCase().endsWith(".gz")) {
            try {
                FileInputStream fin = new FileInputStream(args[i]);
                GZIPInputStream gzin = new GZIPInputStream(fin);
                FileOutputStream fout = new FileOutputStream(args[i].substring(0, args[i].length() - 3));
                for (int c = gzin.read(); c != -1; c = gzin.read()) {
                    fout.write(c);/*from  w  w w  .  j  a  va  2  s  . c om*/
                }
                fout.close();
            } catch (IOException ex) {
                System.err.println(ex);
            }
        } else {
            System.err.println(args[i] + " does not appear to be a gzipped file.");
        }
    }
}

From source file:SettingPageSizeA3.java

public static void main(String[] args) {
    Document document = new Document();
    try {//  w  w  w.  ja v a2s  .c o m
        PdfWriter.getInstance(document, new FileOutputStream("SettingPageSizeA3.pdf"));
        document.open();
        document.add(new Paragraph("First Page."));
        document.setPageSize(PageSize.A3);
        document.newPage();
        document.add(new Paragraph("This PageSize is A3."));
    } 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 path = Paths.get("C:/tutorial/Java/JavaFX");

    DirectoryStream.Filter<Path> dir_filter = new DirectoryStream.Filter<Path>() {
        public boolean accept(Path path) throws IOException {
            return (Files.isDirectory(path, NOFOLLOW_LINKS));
        }//from  w w  w. j  av a  2 s. c o  m
    };

    try (DirectoryStream<Path> ds = Files.newDirectoryStream(path, dir_filter)) {
        for (Path file : ds) {
            System.out.println(file.getFileName());
        }
    } catch (IOException e) {
        System.err.println(e);
    }

}

From source file:GreekListsPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//w ww .  j av a 2  s.c  o m
        PdfWriter.getInstance(document, new FileOutputStream("GreekListsPDF.pdf"));
        document.open();

        GreekList greek = new GreekList(15);
        greek.setGreekLower(true);
        greek.add(new ListItem("first item"));
        greek.add(new ListItem("second item"));
        for (int i = 3; i < 20; i++) {
            greek.add(i + "th item");
        }
        document.add(greek);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:PDFListsAtoE.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from   ww w. j  a  va 2 s .  c om*/
        PdfWriter.getInstance(document, new FileOutputStream("ListsAtoE.pdf"));
        document.open();

        Paragraph paragraph = new Paragraph("A to E:");
        List list = new List(false, 10);
        list.add("A");
        list.add("B");
        list.add("C");
        list.add("D");
        list.add("E");
        paragraph.add(list);
        document.add(paragraph);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}