List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:SimpleTableRowBorderWidthPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50); try {/*from w w w . j av a 2 s . c o m*/ PdfWriter.getInstance(document, new FileOutputStream("SimpleTableRowBorderWidthPDF.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); row.add(cell); row.setBorderWidth(3f); table.addElement(row); document.add(table); } catch (Exception e) { e.printStackTrace(); } document.close(); }
From source file:DrawCrossPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w . j av a2s.c om*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("DrawCrossPDF.pdf")); writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate template = cb.createTemplate(25, 25); template.moveTo(13, 0); template.lineTo(13, 25); template.moveTo(0, 13); template.lineTo(50, 13); template.stroke(); cb.addTemplate(template, 380, 780); cb.addTemplate(template, 160, 480); cb.addTemplate(template, 450, 270); cb.addTemplate(template, 90, 90); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:MultiColumnRegularColumnsPDF.java
public static void main(String[] args) { try {//w w w . jav a2 s. c o m Document document = new Document(); OutputStream out = new FileOutputStream("MultiColumnRegularColumnsPDF.pdf"); PdfWriter.getInstance(document, out); document.open(); MultiColumnText mct = new MultiColumnText(); mct.setColumnsRightToLeft(true); mct.addRegularColumns(document.left(), document.right(), 10f, 3); for (int i = 0; i < 30; i++) { mct.addElement(new Paragraph(String.valueOf(i + 1))); Paragraph p = new Paragraph("text text text text text text text text text text text ", FontFactory.getFont("Helvetica", 10, Font.NORMAL, Color.BLACK)); p.setAlignment(Element.ALIGN_LEFT); p.setLeading(12f); mct.addElement(p); } document.add(mct); document.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:MakingMasksFromByteArrayPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {/*from w w w . java2s.c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("MakingMasksFromByteArrayPDF.pdf")); document.open(); Paragraph p = new Paragraph("Some text behind a masked image."); for (int i = 0; i < 10; i++) { document.add(p); } PdfContentByte cb = writer.getDirectContent(); byte maskr[] = { (byte) 0x77, (byte) 0x77, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x77, (byte) 0x77 }; Image mask = Image.getInstance(8, 8, 1, 1, maskr); mask.makeMask(); mask.setInvertMask(true); cb.setRGBColorFill(255, 0, 0); cb.addImage(mask, mask.scaledWidth() * 8, 0, 0, mask.scaledHeight() * 8, 100, 450); document.close(); } catch (Exception de) { de.printStackTrace(); } }
From source file:MultiColumnSimplePDF.java
public static void main(String[] args) { try {/*w w w .j a v a2s .c o m*/ Document document = new Document(); OutputStream out = new FileOutputStream("MultiColumnSimplePDF.pdf"); PdfWriter.getInstance(document, out); document.open(); MultiColumnText mct = new MultiColumnText(); mct.addRegularColumns(document.left(), document.right(), 10f, 3); for (int i = 0; i < 30; i++) { mct.addElement(new Paragraph(String.valueOf(i + 1))); Paragraph p = 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 ", FontFactory.getFont("Helvetica", 10, Font.BOLDITALIC, Color.BLACK)); p.setAlignment(Element.ALIGN_CENTER); p.setLeading(12f); mct.addElement(p); } document.add(mct); document.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:MainClass.java
public static void main(String[] args) { Connection connection = null; Statement statement = null;//from www . j a v a 2s . c om try { Class.forName("org.gjt.mm.mysql.Driver").newInstance(); String url = "jdbc:mysql://localhost/hrapp"; connection = DriverManager.getConnection(url, "username", "password"); statement = connection.createStatement(); String employees1SQL = "UPDATE employees SET " + "num_dependants = 4 " + "WHERE employee_id = 123456"; statement.executeUpdate(employees1SQL); String employees2SQL = "UPDATE employees SET " + "num_dependants = 4 " + "WHERE employee_id = 123457"; statement.executeUpdate(employees2SQL); } catch (Exception e) { e.printStackTrace(); } finally { if (statement != null) { try { statement.close(); } catch (SQLException e) { } } if (connection != null) { try { connection.close(); } catch (SQLException e) { } } } }
From source file:Main.java
public static void main(String[] args) throws Exception { JFrame frm = new JFrame("Main"); Image im = Toolkit.getDefaultToolkit().getImage("c:\\icons\\icon1.png"); TrayIcon tri = new TrayIcon(im); tri.addActionListener(e -> {/*www . j a v a 2 s.co m*/ frm.setVisible(true); try { SystemTray.getSystemTray().remove(tri); } catch (Exception ex) { ex.printStackTrace(); } }); frm.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { try { SystemTray.getSystemTray().add(tri); } catch (Exception ex) { ex.printStackTrace(); } frm.setVisible(false); } }); frm.setSize(100, 100); frm.setVisible(true); }
From source file:Pattern1PDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {/* www . j a v a 2 s.c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Pattern1PDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(400, 300); PdfPatternPainter pat = cb.createPattern(10, 10, null); pat.setLineWidth(2); pat.moveTo(0, -5); pat.lineTo(15, 10); pat.stroke(); PdfSpotColor spc_cmyk = new PdfSpotColor("PANTONE 280 CV", 0.25f, new CMYKColor(0.9f, .2f, .3f, .1f)); SpotColor spot = new SpotColor(spc_cmyk); tp.setPatternFill(pat, spot, .9f); tp.rectangle(0, 0, 40, 30); tp.fill(); cb.addTemplate(tp, 50, 50); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:SimpleTableRowBackgroundPDF.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("SimpleTableRowBackgroundPDF.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); row.add(cell); row.setBackgroundColor(Color.red); table.addElement(row); document.add(table); } catch (Exception e) { e.printStackTrace(); } document.close(); }
From source file:Main.java
public static void main(String[] args) { String destFile = "luci2.txt"; // Get the line separator for the current platform String lineSeparator = System.getProperty("line.separator"); String line1 = "test"; String line2 = "test1"; String line3 = "test2"; String line4 = "test3"; try (FileOutputStream fos = new FileOutputStream(destFile)) { fos.write(line1.getBytes());/*from w w w .j a v a 2 s.co m*/ fos.write(lineSeparator.getBytes()); fos.write(line2.getBytes()); fos.write(lineSeparator.getBytes()); fos.write(line3.getBytes()); fos.write(lineSeparator.getBytes()); fos.write(line4.getBytes()); // Flush the written bytes to the file fos.flush(); System.out.println("Text has been written to " + (new File(destFile)).getAbsolutePath()); } catch (Exception e2) { e2.printStackTrace(); } }