List of usage examples for java.lang Exception getMessage
public String getMessage()
From source file:LocalGotoPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*ww w. j ava 2s . com*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("LocalGotoPDF.pdf")); document.open(); Paragraph p1 = new Paragraph("If you click on ", FontFactory.getFont(FontFactory.HELVETICA, 12)); p1.add(new Chunk("this word", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 255))) .setLocalGoto("test")); p1.add(" you will automatically jump to another location in this document."); Paragraph p2 = new Paragraph( "Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text"); Paragraph p3 = new Paragraph("This paragraph contains a "); p3.add(new Chunk("local destination", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(255, 0, 0))) .setLocalDestination("test")); document.add(p1); document.add(p2); document.add(p3); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:PhraseWithSeveralChunksAndDifferentFontsPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w. j a v a 2 s. c o m*/ PdfWriter.getInstance(document, new FileOutputStream("PhraseWithSeveralChunksAndDifferentFontsPDF.pdf")); document.open(); Phrase phrase6 = new Phrase("I have several Chunks."); Chunk chunk = new Chunk("Font: "); phrase6.add(chunk); phrase6.add(new Chunk("Helvetica", FontFactory.getFont(FontFactory.HELVETICA, 12))); phrase6.add(chunk); phrase6.add(new Chunk("Times New Roman", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); phrase6.add(chunk); phrase6.add(new Chunk("Courier", FontFactory.getFont(FontFactory.COURIER, 12))); phrase6.add(chunk); phrase6.add(new Chunk("Symbol", FontFactory.getFont(FontFactory.SYMBOL, 12))); phrase6.add(chunk); document.add(Chunk.NEWLINE); phrase6.add(new Chunk("ZapfDingBats", FontFactory.getFont(FontFactory.ZAPFDINGBATS, 12))); document.add(phrase6); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:Main.java
public static void main(String args[]) { try {//from ww w . j av a 2 s. com MongoClient mongoClient = new MongoClient("localhost", 27017); DB db = mongoClient.getDB("test"); System.out.println("Connect to database successfully"); boolean auth = db.authenticate("myUserName", "myPassword".toCharArray()); System.out.println("Authentication: " + auth); DBCollection coll = db.createCollection("mycol", null); System.out.println("Collection created successfully"); coll = db.getCollection("mycol"); System.out.println("Collection mycol selected successfully"); } catch (Exception e) { System.err.println(e.getClass().getName() + ": " + e.getMessage()); } }
From source file:TableCellAlignmentPDF.java
public static void main(String[] args) { Document.compress = false;//from ww w . j a v a 2 s. c o m Document document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream("TableCellAlignmentPDF.pdf")); document.open(); Image img = Image.getInstance("logo.png"); img.scalePercent(10); PdfPTable table = new PdfPTable(3); PdfPCell cell = new PdfPCell(); cell.addElement(new Chunk("cell ")); cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell("a cell"); table.addCell(cell); table.addCell("a cell"); document.add(table); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:TableCellWithBackgroundPDF.java
public static void main(String[] args) { Document.compress = false;// ww w. j av a 2 s.c o m Document document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream("TableCellWithBackgroundPDF.pdf")); document.open(); Image img = Image.getInstance("logo.png"); img.scalePercent(10); PdfPTable table = new PdfPTable(3); PdfPCell cell = new PdfPCell(); cell.addElement(new Chunk("cell ")); cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell("a cell"); table.addCell(cell); table.addCell("a cell"); document.add(table); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:TemplatesTextPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w ww .ja v a 2 s .c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TemplatesTextPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate template = cb.createTemplate(500, 200); template.beginText(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); template.setFontAndSize(bf, 12); template.setTextMatrix(10, 10); template.showText("10,10 (relative to the template!)"); template.endText(); cb.addTemplate(template, 0, 0); document.newPage(); cb.addTemplate(template, 0, 0); cb.addTemplate(template, 2, 0, 0, 2, -200, 400); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:org.openscore.lang.tools.verifier.VerifierMain.java
public static void main(String[] args) { String repositoryPath = args[0]; Validate.notNull(repositoryPath, "You must pass a path to your repository"); repositoryPath = FilenameUtils.separatorsToSystem(repositoryPath); Validate.isTrue(new File(repositoryPath).isDirectory(), "Directory path argument \'" + repositoryPath + "\' does not lead to a directory"); ApplicationContext context = new AnnotationConfigApplicationContext(VerifierSpringConfiguration.class); SlangContentVerifier slangContentVerifier = context.getBean(SlangContentVerifier.class); try {//from w w w . j a va2s . c om int numberOfValidSlangFiles = slangContentVerifier.verifyAllSlangFilesInDirAreValid(repositoryPath); System.out.println("SUCCESS: Found " + numberOfValidSlangFiles + " slang files under directory: \"" + repositoryPath + "\" and all are valid."); System.exit(0); } catch (Exception e) { System.out.println(e.getMessage() + "\n\nFAILURE: Validation of slang files under directory: \"" + repositoryPath + "\" failed."); // TODO - do we want to throw exception or exit with 1? System.exit(1); } }
From source file:Convert2pdfptable.java
public static void main(String[] args) { Document document = new Document(); try {//from ww w . j a v a 2 s .c o m PdfWriter.getInstance(document, new FileOutputStream("Convert2pdfptable.pdf")); document.open(); Table table = new Table(2); table.setBorderWidth(1); table.setPadding(10); Cell cell = new Cell("header"); cell.setHeader(true); cell.setColspan(2); table.addCell(cell); table.addCell("1.1"); table.addCell("2.1"); table.addCell("3.1"); table.addCell("1.2"); table.addCell("2.2"); table.addCell("3.2"); table.setConvert2pdfptable(true); document.add(table); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:MainClass.java
public static void main(String[] arguments) { String data = "jdbc:odbc:YourSettings"; try {/*from w ww. jav a2 s .c o m*/ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection(data, "", ""); Statement st = conn.createStatement(); ResultSet rec = st .executeQuery("SELECT * FROM Coal WHERE (Country='" + arguments[0] + "') ORDER BY Year"); while (rec.next()) { System.out.println(rec.getString(1) + "\t" + rec.getString(2) + "\t\t" + rec.getString(3) + "\t" + rec.getString(4)); } st.close(); } catch (Exception e) { System.out.println("Error: " + e.toString() + e.getMessage()); } }
From source file:TemplateImagesPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {/*from w ww . j av a 2 s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TemplateImagesPDF.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); document.add(new Phrase(new Chunk(img, 0, 0))); document.close(); } catch (Exception de) { System.err.println(de.getMessage()); } }