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

public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    try {//  w w  w.  j  a  v a  2s  .com
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("BarcodesInter25.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();

        BarcodeInter25 code25 = new BarcodeInter25();
        code25.setGenerateChecksum(true);
        code25.setCode("99-1234567890-001");
        Image image25 = code25.createImageWithBarcode(cb, null, null);

        document.add(new Phrase(new Chunk(image25, 0, 0)));
    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}

From source file:TableCellDefaultAlignmentPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4);
    try {//  w  w w  . j av  a  2s .  c  om
        PdfWriter writer = PdfWriter.getInstance(document,
                new FileOutputStream("TableCellDefaultAlignmentPDF.pdf"));

        document.open();

        PdfPTable table = new PdfPTable(3);
        PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3"));
        cell.setColspan(3);
        table.addCell(cell);
        document.add(table);

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

From source file:Main.java

public static void main(String args[]) {
    try {//  w  ww  .  j  ava2  s  . c o m

        int port = 80;

        DatagramSocket ds = new DatagramSocket(port);

        while (true) {
            byte buffer[] = new byte[BUFSIZE];

            DatagramPacket dp = new DatagramPacket(buffer, buffer.length);

            ds.receive(dp);

            String str = new String(dp.getData());

            System.out.println(str);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Test.java

public static void main(String[] args) {
    try (MyResource resource1 = new MyResource(); OtherResource resource2 = new OtherResource()) {
        resource1.do1();
        resource2.do2();
    } catch (Exception e) {
        e.printStackTrace();
        for (Throwable throwable : e.getSuppressed()) {
            System.out.println(throwable);
        }//w w w . j a  v  a 2 s  . com
    }

}

From source file:SpotColorsspc_rgbPDF.java

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

        PdfContentByte cb = writer.getDirectContent();

        PdfSpotColor spc_rgb = new PdfSpotColor("PANTONE 147", 0.9f, new Color(114, 94, 38));

        cb.setColorStroke(spc_rgb, .5f);
        cb.setLineWidth(10f);
        cb.rectangle(100, 700, 100, 100);
        cb.stroke();
    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}

From source file:BarcodesEAN13.java

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

        BarcodeEAN codeEAN = new BarcodeEAN();
        codeEAN.setCodeType(Barcode.EAN13);
        codeEAN.setCode("1234567812345");
        Image imageEAN = codeEAN.createImageWithBarcode(cb, null, null);

        document.add(new Phrase(new Chunk(imageEAN, 0, 0)));
    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}

From source file:com.home.ln_spring.ch5.factory.AccessingFactoryBeans.java

public static void main(String[] args) {
    GenericXmlApplicationContext context = new GenericXmlApplicationContext();

    context.load("classpath:factory/factory.xml");
    context.refresh();//from   w ww .jav  a  2s.  c  o m

    MessageDigest digest = (MessageDigest) context.getBean("shaDigest");

    MessageDigestFactoryBean factoryBean = (MessageDigestFactoryBean) context.getBean("&shaDigest");

    try {
        MessageDigest shaDigest = factoryBean.getObject();
        System.out.println(shaDigest.digest("HELLO WORLD!".getBytes()));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:SpotColorsTintPDF.java

public static void main(String[] args) {
    Document document = new Document();
    try {//  w w  w  .ja  va 2  s  . c  o m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SpotColorsTintPDF.pdf"));
        document.open();

        PdfContentByte cb = writer.getDirectContent();

        PdfSpotColor spc_g = new PdfSpotColor("PANTONE 100 CV", 0.5f, new GrayColor(0.9f));

        cb.setColorStroke(spc_g, .5f);
        cb.setLineWidth(10f);
        cb.setColorFill(spc_g, spc_g.getTint());
        cb.rectangle(100, 700, 100, 100);
        cb.fill();
    } catch (Exception de) {
        de.printStackTrace();
    }
    document.close();
}

From source file:MainClass.java

public static void main(String[] args) {
    try {//w  w  w  . j  a  v  a2  s.  com
        Class c = Class.forName("java.util.ArrayList");

        Constructor constructors[] = c.getDeclaredConstructors();
        for (int i = 0; i < constructors.length; i++) {
            System.out.print(constructors[i].getName() + ": ");
            Class parameters[];
            parameters = constructors[i].getParameterTypes();
            for (int j = 0; j < parameters.length; j++) {
                String s = parameters[j].getName();
                s = s.substring(s.lastIndexOf(".") + 1, s.length());
                System.out.print(s + " ");
            }
            System.out.println("");
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:UpdateRecordsUsingPreparedStatement.java

public static void main(String[] args) throws Exception {
    Connection conn = null;//from   w  ww .  ja va2s  . c o m
    PreparedStatement pstmt = null;
    try {
        conn = getConnection();
        String query = "update dept set DEPT_LOC = ? where DEPT_NUM = ? ";
        pstmt = conn.prepareStatement(query); // create a statement
        pstmt.setString(1, "deptLocation"); // set input parameter 1
        pstmt.setInt(2, 1001); // set input parameter 2
        pstmt.executeUpdate(); // execute update statement
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    } finally {
        pstmt.close();
        conn.close();
    }
}