List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:CellAlignmentJustifiedPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); try {// w w w.j av a2 s . co m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("CellAlignmentJustifiedPDF.pdf")); document.open(); PdfPTable table = new PdfPTable(2); PdfPCell cell; Paragraph p = new Paragraph( "Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text "); table.addCell("default alignment"); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); 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 {//from w w w . ja v a2 s . c o m new Main().runTest(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { Object obj1 = "Object"; Object obj2 = 2;/*from ww w . jav a 2s . c o m*/ Date date = new Date(); try { PrintWriter pw = new PrintWriter(System.out); // print object pw.println(obj1); // print another object pw.println(obj2); // print a date (it is an object) pw.print(date); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:OnParagraphEventPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A6); try {// ww w .j a v a2 s .co m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("OnParagraphEventPDF.pdf")); writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); document.open(); writer.setPageEvent(new OnParagraphEventPDF()); document.add(new Paragraph("Text.", new Font(Font.HELVETICA, 12))); document.add(new Paragraph("Text.", new Font(Font.HELVETICA, 12))); document.add(new Paragraph("Text.", new Font(Font.HELVETICA, 12))); document.add(new Paragraph("Text.", new Font(Font.HELVETICA, 12))); document.add(new Paragraph("Text.", new Font(Font.HELVETICA, 12))); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:CellAlignmentMiddlePDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); try {/*w ww .java2s. c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("CellAlignmentMiddlePDF.pdf")); document.open(); PdfPTable table = new PdfPTable(2); PdfPCell cell; table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); Paragraph p = new Paragraph( "Text Text\nText Text Text\nText\nText\nText\nText\nText\nText\nText Text Text\nText Text\nText "); table.addCell("default alignment"); cell = new PdfPCell(p); table.addCell(cell); document.add(table); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:TableWidthPercentagePDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4); try {/*from www . j av a2 s.com*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TableWidthPercentagePDF.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); table.setWidthPercentage(50); document.add(table); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:org.sharegov.timemachine.StartUp.java
public static void main(String[] argv) { Component server = new Component(); server.getServers().add(Protocol.HTTP, 9192); //server.getClients().add(Protocol.HTTP); //server.getClients().add(Protocol.FILE); final JaxRsApplication app = new JaxRsApplication(server.getContext().createChildContext()); app.add(new TimeMachineRestApplication()); server.getDefaultHost().attach(app); try {/*from w ww . j a v a 2 s . c o m*/ server.start(); new ClassPathXmlApplicationContext("config.xml"); } catch (Exception e) { e.printStackTrace(); } }
From source file:DemoPreparedStatementSetBigDecimal.java
public static void main(String[] args) throws Exception { Connection conn = null;// w w w.ja v a 2 s .c o m PreparedStatement pstmt = null; String query = null; try { conn = getConnection(); query = "insert into BIG_DECIMAL_TABLE(id, big_decimal) values(?, ?)"; pstmt = conn.prepareStatement(query); pstmt.setString(1, "001"); pstmt.setBigDecimal(2, new java.math.BigDecimal("123456789")); // execute query, and return number of rows created int rowCount = pstmt.executeUpdate(); System.out.println("rowCount=" + rowCount); } catch (Exception e) { e.printStackTrace(); } finally { pstmt.close(); conn.close(); } }
From source file:Main.java
public static void main(String args[]) { try {//from www. j a v a2 s . c o m int port = 80; DatagramSocket ds = new DatagramSocket(port); byte buffer[] = new byte[BUFSIZE]; while (true) { DatagramPacket dp = new DatagramPacket(buffer, buffer.length); // Receive data ds.receive(dp); // Display address from the datagram packet InetAddress ia = dp.getAddress(); System.out.println(ia); System.out.println(dp.getPort()); } } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {//w w w .j a v a2s.c om String s = "Hello world from java2s.com"; RandomAccessFile raf = new RandomAccessFile("c:/test.txt", "rw"); raf.writeUTF(s); raf.seek(0); System.out.println(raf.readUTF()); raf.seek(0); raf.writeUTF("This is an example from java2s.com"); raf.seek(0); System.out.println(raf.readUTF()); raf.close(); } catch (Exception ex) { ex.printStackTrace(); } }