List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:Main.java
public static void main(String args[]) { try {//from ww w . j av 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); dp.setLength(10); } } catch (Exception e) { e.printStackTrace(); } }
From source file:ViewerPreferencesPageLayoutTwoColumnRightPageModeFullScreenNonFullScreenPageModeUseThumbs.java
public static void main(String[] args) { Document document = new Document(PageSize.A6); try {//from ww w . j av a2 s.c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream( "ViewerPreferencesPageLayoutTwoColumnRightPageModeFullScreenNonFullScreenPageModeUseThumbs.pdf")); writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnRight | PdfWriter.PageModeFullScreen | PdfWriter.NonFullScreenPageModeUseThumbs); document.addTitle("This is the title."); document.open(); document.add(new Paragraph( "text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text ", new Font(Font.HELVETICA, 12))); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:SplitTablePDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 10, 10, 10, 10); try {//from w w w. j a v a 2s . c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SplitTablePDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfPTable table = new PdfPTable(10); for (int i = 1; i <= 100; ++i) { table.addCell(Integer.toString(i)); } table.setTotalWidth(800); table.writeSelectedRows(0, 5, 0, -1, 50, 650, cb); document.newPage(); table.writeSelectedRows(5, -1, 0, -1, 50, 650, cb); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:Main.java
public static void main(String[] args) { byte[] b = { 'h', 'e', 'l', 'l', 'o' }; try {/*from w w w . j ava2 s. co m*/ OutputStream os = new FileOutputStream("test.txt"); InputStream is = new FileInputStream("test.txt"); os.write(b, 0, 3); for (int i = 0; i < 3; i++) { System.out.print((char) is.read()); } os.close(); is.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:ParagraphAlignJustifiedPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 350, 50, 50); try {/*from w ww .j av a2s .c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ParagraphAlignJustifiedPDF.pdf")); document.open(); String text = "This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph."; Paragraph p = new Paragraph(text); p.setAlignment(Element.ALIGN_JUSTIFIED); //p.setAlignment(Element.ALIGN_RIGHT); //p.setAlignment(Element.ALIGN_MIDDLE); document.add(p); document.newPage(); document.add(p); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:SimpleTableCellWidthPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50); try {/*from w w w .ja va 2s .c o m*/ PdfWriter.getInstance(document, new FileOutputStream("SimpleTableCellWidthPDF.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); table.addElement(row); document.add(table); } catch (Exception e) { e.printStackTrace(); } document.close(); }
From source file:PdfActionGotoLocalPage.java
public static void main(String[] args) { Document document = new Document(); Document remote = new Document(); try {//from ww w . j av a 2 s .co m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("PdfActionGotoLocalPage.pdf")); document.open(); PdfAction action = PdfAction.gotoLocalPage(2, new PdfDestination(PdfDestination.XYZ, -1, 10000, 0), writer); writer.setOpenAction(action); document.add(new Paragraph("Page 1")); document.newPage(); document.add(new Paragraph("Page 2")); } catch (Exception de) { de.printStackTrace(); } document.close(); remote.close(); }
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' }; InputStream is = new ByteArrayInputStream(byteArray); PushbackInputStream pis = new PushbackInputStream(is, 10); try {/* w w w. j av a 2 s. c o m*/ for (int i = 0; i < byteArray.length; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } byte[] b = { 'W', 'o', 'r', 'l', 'd' }; pis.unread(b); for (int i = 0; i < byteArray.length; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } } 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' }; InputStream is = new ByteArrayInputStream(byteArray); PushbackInputStream pis = new PushbackInputStream(is); try {/*from w ww . j av a 2s.c om*/ pis.skip(1); for (int i = 0; i < byteArray.length - 1; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } } 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' }; InputStream is = new ByteArrayInputStream(byteArray); PushbackInputStream pis = new PushbackInputStream(is); try {/*from w w w.j av a2 s . c o m*/ for (int i = 0; i < byteArray.length; i++) { arrByte[i] = (byte) pis.read(); System.out.println((char) arrByte[i]); } pis.mark(5); } catch (Exception ex) { ex.printStackTrace(); } }