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:ThreeParagraphsPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*  ww w .  jav  a  2 s .  c  om*/
        PdfWriter.getInstance(document, new FileOutputStream("ThreeParagraphsPDF.pdf"));
        document.open();
        Paragraph p1 = new Paragraph(
                new Chunk("This is my first paragraph. ", FontFactory.getFont(FontFactory.HELVETICA, 10)));
        document.add(p1);

        Paragraph p2 = new Paragraph(
                new Phrase("This is my second paragraph. ", FontFactory.getFont(FontFactory.HELVETICA, 12)));
        p2.add("a new line.");
        document.add(p2);

        Paragraph p3 = new Paragraph("This is my third paragraph.",
                FontFactory.getFont(FontFactory.HELVETICA, 12));
        document.add(p3);
    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:TemplatesTextPDF.java

public static void main(String[] args) {
    Document document = new Document();

    try {/*from   w  w w  . j a  va  2 s . c  o m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TemplatesTextPDF.pdf"));
        document.open();

        PdfContentByte cb = writer.getDirectContent();
        PdfTemplate template = cb.createTemplate(500, 200);

        template.beginText();
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        template.setFontAndSize(bf, 12);
        template.setTextMatrix(10, 10);
        template.showText("10,10 (relative to the template!)");
        template.endText();

        cb.addTemplate(template, 0, 0);

        document.newPage();
        cb.addTemplate(template, 0, 0);

        cb.addTemplate(template, 2, 0, 0, 2, -200, 400);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:example.Example.java

public static void main(String[] args) {
    if (args.length == 0) {
        System.err.println("Usage: Example username:password ... [-f twitter_id ...] [-t keyword]");
        System.exit(1);//from  ww w. j ava  2  s  . c om
    }

    Collection<String> credentials = new ArrayList<String>();
    Collection<String> followIds = null;
    Collection<String> trackKeywords = null;

    Collection<String> list = credentials;

    for (int i = 0; i < args.length; i++) {
        String arg = args[i];
        if (arg.equals("-f")) {
            followIds = new ArrayList<String>();
            list = followIds;
        } else if (arg.equals("-t")) {
            trackKeywords = new ArrayList<String>();
            list = trackKeywords;
        } else {
            list.add(arg);
        }
    }

    final Collection<String> finalFollowIds = followIds;
    final Collection<String> finalTrackKeywords = trackKeywords;

    FilterParameterFetcher filterParameterFetcher = new FilterParameterFetcher() {
        public Collection<String> getFollowIds() {
            return finalFollowIds;
        }

        public Collection<String> getTrackKeywords() {
            return finalTrackKeywords;
        }
    };

    new TwitterClient(filterParameterFetcher, new ExampleTwitterStreamProcessor(),
            "http://stream.twitter.com/1/statuses/filter.json", 200, 10, credentials, 60 * 1000L).execute();
}

From source file:SAXCopy.java

static public void main(String[] arg) {
    try {//from  ww w  .j a  va 2s .  c  om
        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser parser = spf.newSAXParser();
        XMLReader reader = parser.getXMLReader();
        reader.setErrorHandler(new MyErrorHandler());
        MyCopyHandler duper = new MyCopyHandler();
        reader.setContentHandler(duper);
        InputSource is = new InputSource("test.xml");
        reader.parse(is);
    } catch (SAXException e) {
        System.exit(1);
    } catch (ParserConfigurationException e) {
        System.err.println(e);
        System.exit(1);
    } catch (IOException e) {
        System.err.println(e);
        System.exit(1);
    }
}

From source file:SetExampleV2.java

public static void main(String args[]) {
    // create two sets
    Set set1 = new HashSet();
    set1.add("Red");
    set1.add("Green");

    Set set2 = new HashSet();
    set2.add("Yellow");
    set2.add("Red");

    // create a composite set out of these two
    CompositeSet composite = new CompositeSet();

    // set the class that handles additions, conflicts etc
    // composite.setMutator(new CompositeMutator());

    // initialize the composite with the sets
    // Cannot be used if set1 and set2 intersect is not null and
    // a strategy to deal with it has not been set
    composite.addComposited(new Set[] { set1, set2 });

    // do some addition/deletions
    // composite.add("Pink");
    // composite.remove("Green");

    // whats left in the composite?
    Iterator itr = composite.iterator();

    while (itr.hasNext()) {
        System.err.println(itr.next());
    }//from w  w  w . ja v a 2 s .  c om
}

From source file:GenerateTwoPDFAndHTMLRTF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from  ww  w  .ja va  2 s . c  om*/
        PdfWriter.getInstance(document, new FileOutputStream("AHrefForAWebsite.pdf"));
        HtmlWriter.getInstance(document, new FileOutputStream("AHrefForAWebsite.html"));
        RtfWriter2.getInstance(document, new FileOutputStream("AHrefForAWebsite.html"));

        document.open();

        Paragraph paragraph = new Paragraph("Please visit my ");
        Anchor anchor1 = new Anchor("website (external reference)",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, new Color(0, 0, 255)));
        anchor1.setReference("http://www.java2s.com");
        paragraph.add(anchor1);

        document.add(paragraph);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:DrawTextWithRGBFillPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from   www.  j a  v  a  2s.co  m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("DrawTextWithRGBFillPDF.pdf"));
        document.open();

        PdfContentByte cb = writer.getDirectContent();
        PdfTemplate template = cb.createTemplate(500, 200);
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

        template.beginText();
        template.setFontAndSize(bf, 180);
        template.setRGBColorFill(0xFF, 0x00, 0x00);
        template.showTextAligned(PdfContentByte.ALIGN_LEFT, "PDF", 125f, 35f, 0f);
        template.resetRGBColorFill();
        template.endText();

        cb.addTemplate(template, 0, 1, -1, 0, 500, 200);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:examples.fwhois.java

public static final void main(String[] args) {
    int index;//from w  ww  .ja v  a  2  s . com
    String handle, host;
    InetAddress address = null;
    WhoisClient whois;

    if (args.length != 1) {
        System.err.println("usage: fwhois handle[@<server>]");
        System.exit(1);
    }

    index = args[0].lastIndexOf("@");

    whois = new WhoisClient();
    // We want to timeout if a response takes longer than 60 seconds
    whois.setDefaultTimeout(60000);

    if (index == -1) {
        handle = args[0];
        host = WhoisClient.DEFAULT_HOST;
    } else {
        handle = args[0].substring(0, index);
        host = args[0].substring(index + 1);
    }

    try {
        address = InetAddress.getByName(host);
    } catch (UnknownHostException e) {
        System.err.println("Error unknown host: " + e.getMessage());
        System.exit(1);
    }

    System.out.println("[" + address.getHostName() + "]");

    try {
        whois.connect(address);
        System.out.print(whois.query(handle));
        whois.disconnect();
    } catch (IOException e) {
        System.err.println("Error I/O exception: " + e.getMessage());
        System.exit(1);
    }
}

From source file:StatePDF.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 writer = PdfWriter.getInstance(document, new FileOutputStream("StatePDF.pdf"));
        document.open();

        PdfContentByte cb = writer.getDirectContent();

        cb.setColorFill(Color.red);
        cb.circle(250.0f, 500.0f, 250.0f);
        cb.fill();
        cb.saveState();

        cb.setColorFill(Color.BLACK);
        cb.circle(350.0f, 500.0f, 200.0f);
        cb.fill();
        cb.saveState();

        cb.setColorFill(Color.blue);
        cb.circle(460.0f, 500.0f, 150.0f);
        cb.fill();

        cb.restoreState();
        cb.circle(560.0f, 500.0f, 100.0f);
        cb.fill();

        cb.restoreState();
        cb.circle(660.0f, 500.0f, 50.0f);
        cb.fill();
    } catch (Exception de) {
        System.err.println(de.getMessage());
    }
    document.close();
}

From source file:SimpleAttributeBoldItalicColor.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Simple Attributes");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    StyledDocument document = new DefaultStyledDocument();

    SimpleAttributeSet attributes = new SimpleAttributeSet();
    attributes = new SimpleAttributeSet();
    attributes.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.FALSE);
    attributes.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.FALSE);
    attributes.addAttribute(StyleConstants.CharacterConstants.Foreground, Color.LIGHT_GRAY);

    try {//from   w w  w.  j a  va  2  s.c  om
        document.insertString(document.getLength(), " Bold, Italic and light gray color", attributes);
    } catch (BadLocationException badLocationException) {
        System.err.println("Bad insert");
    }

    JTextPane textPane = new JTextPane(document);
    textPane.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textPane);

    frame.add(scrollPane, BorderLayout.CENTER);

    frame.setSize(300, 150);
    frame.setVisible(true);
}