Example usage for java.lang Exception printStackTrace

List of usage examples for java.lang Exception printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:DestinationsPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {/*from  w w  w . jav  a 2  s  . c  o  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("DestinationsPDF.pdf"));
        writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
        document.open();

        PdfContentByte cb = writer.getDirectContent();

        PdfDestination d1 = new PdfDestination(PdfDestination.XYZ, 300, 800, 0);
        PdfDestination d2 = new PdfDestination(PdfDestination.FITH, 500);
        PdfDestination d3 = new PdfDestination(PdfDestination.FITR, 200, 300, 400, 500);
        PdfDestination d4 = new PdfDestination(PdfDestination.FITBV, 100);
        PdfDestination d5 = new PdfDestination(PdfDestination.FIT);

        PdfOutline out1 = new PdfOutline(cb.getRootOutline(), d1, "root");
        PdfOutline out2 = new PdfOutline(out1, d2, "sub 1");
        PdfOutline out3 = new PdfOutline(out1, d3, "sub 2");
        PdfOutline out4 = new PdfOutline(out2, d4, "sub 2.1");
        PdfOutline out5 = new PdfOutline(out2, d5, "sub 2.2");
        document.add(new Paragraph("adasd"));
        document.newPage();
    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}

From source file:RightToLeftPDF.java

public static void main(String[] args) {
    try {/*w ww.j a  va 2 s . c  o  m*/
        Document document = new Document(PageSize.A4, 50, 50, 50, 50);
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("RightToLeftPDF.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();

        ColumnText ct = new ColumnText(cb);
        ct.setSimpleColumn(100, 100, 500, 800, 24, Element.ALIGN_LEFT);
        ct.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
        ct.setLeading(0, 1);
        ct.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
        ct.setAlignment(Element.ALIGN_CENTER);
        ct.addText(new Chunk("ABCD"));
        ct.go();
        ct.setAlignment(Element.ALIGN_JUSTIFIED);
        ct.addText(new Chunk("ABCD"));
        ct.go();
        ct.setAlignment(Element.ALIGN_CENTER);
        ct.addText(new Chunk("ABCD"));
        ct.go();

        document.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:StdErrOutWindows.java

public static void main(String[] args) {
    new StdErrOutWindows();
    System.out.println("test to out");
    try {/*from w  ww.j  av a  2s  .c o  m*/
        throw new Exception("Test exception");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:SimpleTableCellSpaceLeftPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50);
    try {//from   ww  w . j  a  va  2  s .c  o m
        PdfWriter.getInstance(document, new FileOutputStream("SimpleTableCellSpaceLeftPDF.pdf"));
        document.open();

        SimpleTable table = new SimpleTable();
        SimpleCell row = new SimpleCell(SimpleCell.ROW);
        SimpleCell cell = new SimpleCell(SimpleCell.CELL);
        cell.add(new Paragraph("B"));
        cell.setWidth(100f);
        row.add(cell);

        cell = new SimpleCell(SimpleCell.CELL);
        cell.add(new Paragraph("A"));
        cell.setWidth(50f);
        cell.setSpacing_left(20f);

        row.add(cell);

        table.addElement(row);
        document.add(table);
    } catch (Exception e) {
        e.printStackTrace();
    }
    document.close();
}

From source file:AddPageNumbersToExistingPageNumberPDF.java

public static void main(String[] args) {
    try {/*from w  w  w .jav a  2  s.co m*/
        PdfReader reader = new PdfReader("YourOwnPDF.pdf");
        int n = reader.getNumberOfPages();

        PdfStamper stamp = new PdfStamper(reader,
                new FileOutputStream("AddPageNumbersToExistingPageNumberPDF.pdf"));

        int i = 0;

        PdfContentByte over;
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
        while (i < n) {
            i++;
            over = stamp.getOverContent(i);
            over.beginText();
            over.setFontAndSize(bf, 18);
            over.setTextMatrix(30, 30);
            over.showText("page " + i);
            over.setFontAndSize(bf, 32);
            over.showTextAligned(Element.ALIGN_LEFT, "DUPLICATE", 230, 430, 45);
            over.endText();
        }
        stamp.close();
    } catch (Exception de) {
        de.printStackTrace();
    }
}

From source file:UseStylesheetPI.java

public static void main(String[] args) throws TransformerException, TransformerConfigurationException {
    String media = null, title = null, charset = null;
    try {/*from  w  w  w  . j  a  v  a2s  .co  m*/
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Source stylesheet = tFactory.getAssociatedStylesheet(new StreamSource("fooX.xml"), media, title,
                charset);

        Transformer transformer = tFactory.newTransformer(stylesheet);

        transformer.transform(new StreamSource("fooX.xml"),
                new StreamResult(new java.io.FileOutputStream("foo.out")));

        System.out.println("************* The result is in foo.out *************");

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:SimpleTableCellAlignmentPDF.java

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

        SimpleTable table = new SimpleTable();
        SimpleCell row = new SimpleCell(SimpleCell.ROW);
        SimpleCell cell = new SimpleCell(SimpleCell.CELL);
        cell.add(new Paragraph("B"));
        cell.setWidth(100f);
        row.add(cell);

        cell = new SimpleCell(SimpleCell.CELL);
        cell.add(new Paragraph("A"));
        cell.setWidth(50f);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);

        row.add(cell);

        table.addElement(row);
        document.add(table);
    } catch (Exception e) {
        e.printStackTrace();
    }
    document.close();
}

From source file:CellGrayScalePDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4);
    try {/*from   ww w .jav  a2s.co  m*/
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("CellGrayScalePDF.pdf"));

        document.open();

        PdfPTable table = new PdfPTable(1);
        PdfPCell cell = new PdfPCell(new Paragraph("0.25"));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setGrayFill(0.25f);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("0.5"));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setGrayFill(0.5f);
        table.addCell(cell);
        cell = new PdfPCell(new Paragraph("0.75"));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setGrayFill(0.75f);
        table.addCell(cell);

        document.add(table);
    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}

From source file:com.tc.simple.apn.quicktests.SaveFeedbackData.java

/**
 * @param args//from w ww.  j a v  a2  s.  co m
 * @throws IOException 
 */
public static void main(String[] args) {
    try {

        InputStream in = SaveFeedbackData.class.getResourceAsStream("webshell-dev.p12");

        byte[] p12 = IOUtils.toByteArray(in);

        SocketWrapper feedback = new APNSocketPool().feedBack(p12, "xxxxxxxxx", false);

        IOUtils.copy(feedback.getSocket().getInputStream(),
                new FileOutputStream("c:/temp/feedbackservice.apn", true));

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:Capture.java

public static void main(String[] args) {
    JFrame capture = new JFrame();
    capture.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Toolkit kit = Toolkit.getDefaultToolkit();
    final Dimension d = kit.getScreenSize();
    capture.setSize(d);/* w  ww .j a v  a2 s .  c o  m*/

    Rectangle rect = new Rectangle(d);
    try {
        Robot robot = new Robot();
        final BufferedImage image = robot.createScreenCapture(rect);
        image.flush();
        JPanel panel = new JPanel() {
            public void paintComponent(Graphics g) {
                g.drawImage(image, 0, 0, d.width, d.height, this);
            }
        };
        panel.setOpaque(false);
        panel.prepareImage(image, panel);
        panel.repaint();
        capture.getContentPane().add(panel);
    } catch (Exception e) {
        e.printStackTrace();
    }

    capture.setVisible(true);
}