Example usage for java.lang Exception getMessage

List of usage examples for java.lang Exception getMessage

Introduction

In this page you can find the example usage for java.lang Exception getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:ThreeParagraphsPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from ww  w  .j  av a 2 s . com*/
        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:OutlineActionsHyperLinkPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*ww  w  .j  ava2  s  .c om*/
        PdfWriter writer = PdfWriter.getInstance(document,
                new FileOutputStream("OutlineActionsHyperLinkPDF.pdf"));
        writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
        document.open();
        document.add(new Paragraph("Outline action example"));

        PdfContentByte cb = writer.getDirectContent();
        PdfOutline root = cb.getRootOutline();
        PdfOutline links = new PdfOutline(root, new PdfAction("http://www.java2s.com"), "Useful links");
        links.setColor(new Color(0xFF, 0x00, 0x00));
        links.setStyle(Font.BOLD);

    } catch (Exception ioe) {
        System.err.println(ioe.getMessage());
    }
    document.close();
}

From source file:JumpLocalDestinationPDF.java

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

        document.open();

        Paragraph paragraph = new Paragraph();
        Anchor anchor1 = new Anchor("some text",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, new Color(0, 0, 255)));
        anchor1.setName("top");
        paragraph.add(anchor1);
        document.add(paragraph);

        Anchor anchor2 = new Anchor("please jump to a local destination",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 255)));
        anchor2.setReference("#top");
        document.add(anchor2);

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

From source file:TwoNestedTablesPDF.java

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

        Table secondTable = new Table(2);
        secondTable.addCell("0.0");
        secondTable.addCell("0.1");
        secondTable.addCell("1.0");
        secondTable.addCell("1.1");

        Table aTable = new Table(4, 4); // 4 rows, 4 columns
        aTable.setAutoFillEmptyCells(true);
        aTable.addCell("2.2", new Point(2, 2));
        aTable.insertTable(secondTable, new Point(3, 3));
        aTable.addCell("2.1", new Point(2, 1));
        aTable.insertTable(secondTable, new Point(1, 3));
        document.add(aTable);
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:GStatePDF.java

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

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

        PdfContentByte cb = writer.getDirectContent();
        PdfGState gs = new PdfGState();
        gs.setFillOpacity(0.5f);
        cb.setGState(gs);

        cb.setColorFill(Color.red);
        cb.circle(360.0f, 500.0f, 250.0f);
        cb.fill();
        gs.setFillOpacity(0.2f);
        cb.setGState(gs);
        cb.setColorFill(Color.blue);
        cb.circle(460.0f, 500.0f, 100.0f);
        cb.fill();
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:BufferConverter.java

public static void main(String[] arguments) {
    try {/*from  www .  ja v a2s .  c o  m*/
        String data = "friends.dat";
        FileInputStream inData = new FileInputStream(data);
        FileChannel inChannel = inData.getChannel();
        long inSize = inChannel.size();
        ByteBuffer source = ByteBuffer.allocate((int) inSize);
        inChannel.read(source, 0);
        source.position(0);
        for (int i = 0; source.remaining() > 0; i++)
            System.out.print(source.get() + " ");

        source.position(0);
        Charset ascii = Charset.forName("US-ASCII");
        CharsetDecoder toAscii = ascii.newDecoder();
        CharBuffer destination = toAscii.decode(source);
        destination.position(0);
        System.out.println("\n\nNew character data:");
        for (int i = 0; destination.remaining() > 0; i++)
            System.out.print(destination.get());
    } catch (Exception ioe) {
        System.out.println(ioe.getMessage());
    }
}

From source file:AddingImageToTableCellPDF.java

public static void main(String[] args) {
    Document.compress = false;//from w  w  w.j  a v a 2 s.c  o  m
    Document document = new Document();
    try {
        PdfWriter.getInstance(document, new FileOutputStream("AddingImageToTableCellPDF.pdf"));

        document.open();

        Image img = Image.getInstance("logo.png");
        img.scalePercent(10);

        PdfPTable table = new PdfPTable(3);
        PdfPCell cell = new PdfPCell();
        cell.addElement(new Chunk(img, 5, -5));

        table.addCell("a cell");
        table.addCell(cell);
        table.addCell("a cell");

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

From source file:Main.java

public static void main(String args[]) {
    try {/*from  w  w  w  . j  ava2 s  .co  m*/
        MongoClient mongoClient = new MongoClient("localhost", 27017);

        DB db = mongoClient.getDB("test");
        System.out.println("Connect to database successfully");
        boolean auth = db.authenticate("myUser", "myPassword".toCharArray());
        System.out.println("Authentication: " + auth);
    } catch (Exception e) {
        System.err.println(e.getClass().getName() + ": " + e.getMessage());
    }
}

From source file:PageLabelsPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from w  w  w .j  a va 2s. co  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("PageLabelsPDF.pdf"));
        writer.setViewerPreferences(PdfWriter.PageModeUseThumbs);
        document.open();

        PdfPageLabels pageLabels = new PdfPageLabels();
        pageLabels.addPageLabel(1, PdfPageLabels.LOWERCASE_ROMAN_NUMERALS);
        pageLabels.addPageLabel(2, PdfPageLabels.UPPERCASE_LETTERS);
        pageLabels.addPageLabel(3, PdfPageLabels.LOWERCASE_LETTERS);
        pageLabels.addPageLabel(4, PdfPageLabels.UPPERCASE_ROMAN_NUMERALS);
        pageLabels.addPageLabel(5, PdfPageLabels.DECIMAL_ARABIC_NUMERALS);
        pageLabels.addPageLabel(8, PdfPageLabels.DECIMAL_ARABIC_NUMERALS, "A-", 8);
        writer.setPageLabels(pageLabels);

        for (int i = 1; i <= 10; ++i) {
            document.add(new Paragraph("Page " + i));
            document.newPage();
        }
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
    document.close();
}

From source file:AddingNewLinePDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//  www  .  j  a va 2 s. c  o m
        PdfWriter pdf = PdfWriter.getInstance(document, new FileOutputStream("AddingNewLinePDF.pdf"));
        RtfWriter2 rtf = RtfWriter2.getInstance(document, new FileOutputStream("AddingNewLine.rtf"));
        HtmlWriter html = HtmlWriter.getInstance(document, new FileOutputStream("AddingNewLine.html"));

        document.open();
        document.add(new Paragraph("Some text"));

        Anchor pdfRef = new Anchor("http://www.java2s.com");
        pdfRef.setReference("http://www.java2s.com");
        Anchor rtfRef = new Anchor("Link for aFile.rtf.");
        rtfRef.setReference("./aFile.rtf");

        document.add(pdfRef);
        document.add(Chunk.NEWLINE);
        document.add(rtfRef);

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