List of usage examples for java.lang Exception getMessage
public String getMessage()
From source file:RemoteGotoPDF.java
public static void main(String[] args) { Document document = new Document(); try {// w w w . j a v a2s . c o m PdfWriter writerA = PdfWriter.getInstance(document, new FileOutputStream("DocumentA.pdf")); PdfWriter writerB = PdfWriter.getInstance(document, new FileOutputStream("DocumentB.pdf")); document.open(); Paragraph pa = new Paragraph( new Chunk("Click this paragraph to go to a certain destination on document B") .setRemoteGoto("DocumentB.pdf", "test")); Paragraph pb = new Paragraph( new Chunk("Click this paragraph to go to a certain destination on document A") .setRemoteGoto("DocumentA.pdf", "test")); // a special remote goto Paragraph pc = new Paragraph("you can also jump to a "); pc.add(new Chunk("specific page on another document", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.ITALIC)).setRemoteGoto("DocumentB.pdf", 1)); document.add(pa); document.add(pb); document.add(pc); document.add(pa); document.add(pb); document.add(pc); document.add(pa); document.add(pb); document.add(pc); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:LayersPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w w w . java 2 s.c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("LayersPDF.pdf")); writer.setPdfVersion(PdfWriter.VERSION_1_5); writer.setViewerPreferences(PdfWriter.PageModeUseOC); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfLayer l1 = new PdfLayer("Layer 1", writer); PdfLayer l2 = new PdfLayer("Layer 2", writer); PdfLayer l3 = new PdfLayer("Layer 3", writer); PdfLayerMembership m1 = new PdfLayerMembership(writer); m1.addMember(l1); m1.addMember(l2); m1.addMember(l3); cb.beginLayer(l1); ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, new Phrase("Text in layer 1"), 50, 600, 0); cb.endLayer(); cb.beginLayer(l2); ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, new Phrase("Text in layer 2"), 50, 550, 0); cb.endLayer(); cb.beginLayer(l3); ColumnText.showTextAligned(cb, Element.ALIGN_LEFT, new Phrase("Text in layer 3"), 50, 500, 0); cb.endLayer(); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:TemplateImagesScaleHeightPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {//from w w w. j av a2 s. c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TemplateImagesScaleHeightPDF.pdf")); document.open(); PdfTemplate template = writer.getDirectContent().createTemplate(20, 20); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); String text = "Vertical"; float size = 16; float width = bf.getWidthPoint(text, size); template.beginText(); template.setFontAndSize(bf, size); template.setTextMatrix(0, 2); template.showText(text); template.endText(); template.setWidth(width); template.setHeight(size + 2); Image img = Image.getInstance(template); img.setRotationDegrees(90); Paragraph p1 = new Paragraph("This is a template "); p1.add(new Phrase(new Chunk(img, 0, 0))); p1.setLeading(img.scaledHeight() * 1.1f); document.add(p1); document.close(); } catch (Exception de) { System.err.println(de.getMessage()); } }
From source file:ThreeColumnsPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w . ja v a 2 s. c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ThreeColumnsPDF.pdf")); document.open(); BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); Font font = new Font(bf, 11, Font.NORMAL); Phrase col1 = new Phrase(15, "col1", font); Phrase col2 = new Phrase(15, "col2", font); Phrase col3 = new Phrase(15, "col3", font); for (int i = 0; i < 40; i++) { col1.add("col 1\n"); col2.add("col 2\n"); col3.add("col 3\n"); } PdfContentByte cb = writer.getDirectContent(); ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(col1, 60, 300, 100, 300 + 28 * 15, 15, Element.ALIGN_CENTER); ct.go(); ct.setSimpleColumn(col2, 105, 300, 150, 300 + 28 * 15, 15, Element.ALIGN_RIGHT); ct.go(); ct.setSimpleColumn(col3, 160, 300, 500, 300 + 28 * 15, 15, Element.ALIGN_LEFT); ct.go(); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:LayersGroupPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w. j a v a 2 s . com*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("LayersGroupPDF.pdf")); writer.setPdfVersion(PdfWriter.VERSION_1_5); writer.setViewerPreferences(PdfWriter.PageModeUseOC); document.open(); PdfLayer l1 = new PdfLayer("Layer 1", writer); PdfLayer l2 = new PdfLayer("Layer 2", writer); PdfLayer l3 = new PdfLayer("Layer 3", writer); PdfLayerMembership m1 = new PdfLayerMembership(writer); m1.addMember(l1); m1.addMember(l2); m1.addMember(l3); PdfOCProperties p = writer.getOCProperties(); PdfArray order = new PdfArray(); order.add(l1.getRef()); PdfArray group = new PdfArray(); group.add(new PdfString("A group of two", PdfObject.TEXT_UNICODE)); group.add(l2.getRef()); group.add(l3.getRef()); order.add(group); PdfDictionary d = new PdfDictionary(); d.put(PdfName.ORDER, order); p.put(PdfName.D, d); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:com.apress.prospringintegration.springenterprise.stocks.runner.MainTxJdbc.java
public static void main(String[] args) { GenericApplicationContext context = new AnnotationConfigApplicationContext( "com.apress.prospringintegration.springenterprise.stocks.transactions.template", "com.apress.prospringintegration.springenterprise.stocks.dao.jdbc"); TransactionalStockBrokerService uStockDao = context.getBean("transactionalStockBrokerService", TransactionalStockBrokerService.class); try {/* ww w . j a v a2s . co m*/ uStockDao.preFillStocks("TEST", "IBM", "INTC", "MSFT", "ORAC", "C"); } catch (Exception ex) { System.out.println("Exception: " + ex.getMessage()); } StockDao stockDao = context.getBean(JdbcTemplateStockDao.class); System.out.println("Total rows inserted: " + stockDao.get().size()); for (Stock s : stockDao.get()) { System.out.println("Stock added: " + s.getSymbol()); } }
From source file:StatePDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w w w . j av a2 s . c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("StatePDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.setColorFill(Color.red); cb.circle(250.0f, 500.0f, 250.0f); cb.fill(); cb.saveState(); cb.setColorFill(Color.BLACK); cb.circle(350.0f, 500.0f, 200.0f); cb.fill(); cb.saveState(); cb.setColorFill(Color.blue); cb.circle(460.0f, 500.0f, 150.0f); cb.fill(); cb.restoreState(); cb.circle(560.0f, 500.0f, 100.0f); cb.fill(); cb.restoreState(); cb.circle(660.0f, 500.0f, 50.0f); cb.fill(); } catch (Exception de) { System.err.println(de.getMessage()); } document.close(); }
From source file:org.httpclient.lesson02.java
public static void main(String[] args) { HttpClient httpclient = new DefaultHttpClient(); try {//from ww w . j ava 2s . c om HttpGet get = new HttpGet("http://www.google.com"); System.out.println("execute request: " + get.getURI()); //create a response hendler ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = httpclient.execute(get, responseHandler); System.out.println("===================================="); System.out.println(responseBody); System.out.println("===================================="); } catch (Exception e) { System.out.println(e.getMessage()); } finally { //??? httpclient.getConnectionManager().shutdown(); } }
From source file:StandardFontsPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w ww .j a v a2 s. c o m PdfWriter.getInstance(document, new FileOutputStream("StandardFontsPDF.pdf")); document.open(); document.add(new Paragraph("new Font(Font.COURIER, Font.DEFAULTSIZE, Font.NORMAL", new Font(Font.COURIER, Font.DEFAULTSIZE, Font.NORMAL))); document.add(new Paragraph("new Font(Font.COURIER, Font.DEFAULTSIZE, Font.ITALIC)", new Font(Font.COURIER, Font.DEFAULTSIZE, Font.ITALIC))); document.add(new Paragraph("new Font(Font.COURIER, Font.DEFAULTSIZE, Font.BOLD)", new Font(Font.COURIER, Font.DEFAULTSIZE, Font.BOLD))); document.add(new Paragraph("new Font(Font.COURIER, Font.DEFAULTSIZE, Font.BOLD | Font.ITALIC)", new Font(Font.COURIER, Font.DEFAULTSIZE, Font.BOLD | Font.ITALIC))); document.add(new Paragraph("new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.NORMAL)", new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.NORMAL))); document.add(new Paragraph("new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.ITALIC)", new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.ITALIC))); document.add(new Paragraph("new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLD)", new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLD))); document.add(new Paragraph("new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLDITALIC)", new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLDITALIC))); document.add(new Paragraph("new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.NORMAL)", new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.NORMAL))); document.add(new Paragraph("new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.ITALIC)", new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.ITALIC))); document.add(new Paragraph("new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLD)", new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLD))); document.add(new Paragraph("new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLDITALIC)", new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLDITALIC))); document.add(new Paragraph("new Font(Font.SYMBOL)", new Font(Font.SYMBOL))); document.add(new Paragraph("new Font(Font.ZAPFDINGBATS)", new Font(Font.ZAPFDINGBATS))); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:InsertTextFileToOracle.java
public static void main(String[] args) throws Exception { String id = "001"; String fileName = "fileName.txt"; FileInputStream fis = null;//from w w w . j av a 2s.co m PreparedStatement pstmt = null; Connection conn = null; try { conn = getConnection(); conn.setAutoCommit(false); File file = new File(fileName); fis = new FileInputStream(file); pstmt = conn.prepareStatement("insert into DataFiles(id, fileName, fileBody) values (?, ?, ?)"); pstmt.setString(1, id); pstmt.setString(2, fileName); pstmt.setAsciiStream(3, fis, (int) file.length()); pstmt.executeUpdate(); conn.commit(); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); e.printStackTrace(); } finally { pstmt.close(); fis.close(); conn.close(); } }