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

public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    try {// ww w. jav  a2  s  . c  om
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TableEvents1PDF.pdf"));
        document.open();
        PdfPTable table = new PdfPTable(1);
        table.addCell("a");
        TableEvents1PDF event = new TableEvents1PDF();
        table.setTableEvent(new MyTableEvent());

        document.add(table);

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

From source file:UsingBaseFontPDF.java

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

        PdfContentByte cb = writer.getDirectContent();
        document.newPage();

        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        cb.beginText();
        cb.setFontAndSize(bf, 14);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "www.java2s.com", 100 / 2, 40, 0);
        cb.endText();

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

From source file:TableHorizontalAlignmentRightPDF.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4);
    try {//ww  w .j a v a2  s  .c  o  m
        PdfWriter writer = PdfWriter.getInstance(document,
                new FileOutputStream("TableHorizontalAlignmentRightPDF.pdf"));

        document.open();

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

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

From source file:BarcodesSUPP5.java

public static void main(String[] args) {
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    try {//from ww w. j  av  a2s  . c o m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("BarcodesSUPP5.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();

        BarcodeEAN codeSUPP = new BarcodeEAN();
        codeSUPP.setCodeType(Barcode.SUPP5);
        codeSUPP.setCode("12345");
        codeSUPP.setBaseline(-2);
        Image imagePost = codeSUPP.createImageWithBarcode(cb, null, null);

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

From source file:KeyTools.java

public static void main(String[] rgstring) {
    try {//from   ww  w.  j  a  v a  2s . c  o  m
        File filePublic = new File(rgstring[0]);
        File filePrivate = new File(rgstring[1]);

        KeyPairGenerator keypairgenerator = KeyPairGenerator.getInstance("DSA");

        keypairgenerator.initialize(1024, new SecureRandom());

        KeyPair keypair = keypairgenerator.generateKeyPair();

        writeToFile(keypair.getPublic(), filePublic);
        writeToFile(keypair.getPrivate(), filePrivate);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:TextPatternColorPDF.java

License:asdf

public static void main(String[] args) {
    Document document = new Document();
    try {//from   w  w w . j av a  2  s.  co m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TextPatternColorPDF.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();

        PdfPatternPainter p = cb.createPattern(6f, 6f, 6f, 6f);
        p.setColorFill(Color.red);
        p.circle(2, 2, 2);
        p.stroke();

        document.add(new Paragraph("asdfasdf",
                FontFactory.getFont(FontFactory.HELVETICA, 60, Font.BOLD, new PatternColor(p))));

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

From source file:Main.java

public static void main(String args[]) {
    try {/*from   www  . j  a  v  a  2 s . com*/

        int port = 80;

        DatagramSocket ds = new DatagramSocket(port);

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

            DatagramPacket dp = new DatagramPacket(buffer, buffer.length, InetAddress.getByName("google.com"),
                    8080);

            ds.receive(dp);

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

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

From source file:Main.java

public static void main(String[] args) {
    try {//from  www. j a v  a  2  s.  c  om
        String[] cmdArray = new String[2];
        // the program to open
        cmdArray[0] = "notepad.exe";

        // txt file to open with notepad
        cmdArray[1] = "test.txt";

        File dir = new File("c:/");

        String[] envArray = new String[2];
        envArray[0] = "";
        envArray[1] = "";

        Runtime runTime = Runtime.getRuntime();

        Process process = runTime.exec(cmdArray, envArray, dir);

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

}

From source file:Main.java

public static void main(String[] args) {

    byte[] arrByte = new byte[1024];

    byte[] byteArray = new byte[] { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' };

    // create object of PushbackInputStream class for specified stream
    InputStream is = new ByteArrayInputStream(byteArray);
    PushbackInputStream pis = new PushbackInputStream(is);

    try {/*w ww .  j  a v a 2 s .com*/

        // read a char into our array
        pis.read(arrByte, 0, 3);

        // print arrByte
        for (int i = 0; i < 3; i++) {
            System.out.println((char) arrByte[i]);
        }

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

From source file:Main.java

public static void main(String[] args) {

    try {//from  ww  w  .  ja v a  2 s . c  om
        PipedWriter writer = new PipedWriter();
        PipedReader reader = new PipedReader(writer, 100);

        // connect the reader and the writer
        reader.connect(writer);

        writer.write(70);
        writer.write(71);

        // check if reader is ready to read
        System.out.println(reader.ready());

        // print the char array
        for (int i = 0; i < 2; i++) {
            System.out.println("" + (char) reader.read());
        }
        reader.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}