List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:SOAPRequest.java
public static void main(String[] args) { try {/*from ww w.ja v a 2s. c o m*/ SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance(); SOAPConnection connection = sfc.createConnection(); MessageFactory mf = MessageFactory.newInstance(); SOAPMessage sm = mf.createMessage(); SOAPHeader sh = sm.getSOAPHeader(); SOAPBody sb = sm.getSOAPBody(); sh.detachNode(); QName bodyName = new QName("http://quoteCompany.com", "GetQuote", "d"); SOAPBodyElement bodyElement = sb.addBodyElement(bodyName); QName qn = new QName("aName"); SOAPElement quotation = bodyElement.addChildElement(qn); quotation.addTextNode("TextMode"); System.out.println("\n Soap Request:\n"); sm.writeTo(System.out); System.out.println(); URL endpoint = new URL("http://yourServer.com"); SOAPMessage response = connection.call(sm, endpoint); System.out.println(response.getContentDescription()); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:test.gov.nih.nci.system.web.client.ProductDeleteClient.java
public static void main(String[] args) { try {//from w ww.ja v a 2 s . com if (args == null || args.length != 1) { System.out.println("Usage: RESTFulReadClient <RESTful resource URL>"); return; } String url = args[0]; RESTfulDeleteClient client = new RESTfulDeleteClient(); Response response = client.delete(url); InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); System.out.println(jDoc.toString()); } catch (Exception e) { e.printStackTrace(); } }
From source file:MainClass.java
public static void main(String args[]) { try {/*from w w w .j a v a 2s .c o m*/ SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser saxParser = factory.newSAXParser(); DefaultHandler handler = new DefaultHandler() { boolean name = false; public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (qName.equalsIgnoreCase("NAME")) { name = true; } } public void characters(char ch[], int start, int length) throws SAXException { if (name) { System.out.println("Name: " + new String(ch, start, length)); name = false; } } }; saxParser.parse(new InputSource(new StringReader(xmlString)), handler); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { Connection conn = null;// ww w . j av a2 s . c o m Statement stmt = null; boolean executeResult; try { String driver = "oracle.jdbc.driver.OracleDriver"; Class.forName(driver).newInstance(); System.out.println("Connecting to database..."); String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:ORCL"; conn = DriverManager.getConnection(jdbcUrl, "yourName", "mypwd"); stmt = conn.createStatement(); conn.setAutoCommit(false); if (!conn.getAutoCommit()) System.out.println("Auto-commit is set to false"); String sql = "INSERT INTO Location VALUES(715,'Houston')"; stmt.executeUpdate(sql); sql = "INSERT INTO Employees VALUES" + "(8,'K','4351',{d '2000-02-00'},715)"; stmt.executeUpdate(sql); conn.commit(); } catch (SQLException se) { String msg = se.getMessage(); msg = "SQLException occured with message: " + msg; System.out.println(msg); System.out.println("Starting rollback operations..."); try { conn.rollback(); } catch (SQLException se2) { se2.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:ImageMasksPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {//ww w .ja va2 s .c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ImageMasksPDF.pdf")); document.open(); Paragraph p = new Paragraph("Some text behind a masked image."); for (int i = 0; i < 50; 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); Image image = Image.getInstance("logo.png"); image.setImageMask(mask); image.setAlignment(Image.TEXTWRAP); image.setAbsolutePosition(60, 550); cb.addImage(image); document.close(); } catch (Exception de) { de.printStackTrace(); } }
From source file:Main.java
public static void main(final String[] args) { try {//from www.j ava2s .c o m int[] x = new int[] { 2, 3, 8, 7, 5 }; char[] y = new char[] { 'a', 'z', 'e' }; String[] z = new String[] { "Jim", "John", "Joe" }; System.out.println(" -- z and copy of z --"); outputArrays(z, copyArray(z)); } catch (final Exception ex) { ex.printStackTrace(); } }
From source file:MainClass.java
public static void main(String args[]) { try {/*from w w w.jav a2s. co m*/ InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); while (true) { System.out.print("Radius? "); String str = br.readLine(); double radius; try { radius = Double.valueOf(str).doubleValue(); } catch (NumberFormatException nfe) { System.out.println("Incorrect format!"); continue; } if (radius <= 0) { System.out.println("Radius must be positive!"); continue; } double area = Math.PI * radius * radius; System.out.println("Area is " + area); return; } } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); BufferedImage image = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); f.getContentPane().add(new JLabel(new ImageIcon(dye(image, new Color(255, 0, 0, 128))))); f.pack();/* w w w.j a v a 2 s. c o m*/ f.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:FontListPDF.java
public static void main(String[] args) { try {//from ww w .j a v a2s . c o m Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("FontListPDF.pdf")); document.open(); Paragraph p = new Paragraph(); p.add(new Chunk("Font.TIMES_ROMAN", new Font(Font.TIMES_ROMAN, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.ZAPFDINGBATS", new Font(Font.ZAPFDINGBATS, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.SYMBOL", new Font(Font.SYMBOL, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.BOLD|Font.SYMBOL", new Font(Font.BOLD | Font.SYMBOL, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.STRIKETHRU", new Font(Font.STRIKETHRU, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.STRIKETHRU|Font.BOLDITALIC", new Font(Font.STRIKETHRU | Font.BOLDITALIC, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.HELVETICA", new Font(Font.HELVETICA, 12))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.HELVETICA", new Font(Font.HELVETICA, Font.DEFAULTSIZE))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.UNDERLINE", new Font(Font.UNDERLINE, Font.DEFAULTSIZE))); p.add(Chunk.NEWLINE); p.add(new Chunk("Font.COURIER ", new Font(Font.COURIER, Font.DEFAULTSIZE))); document.add(new Paragraph(p)); document.close(); } catch (Exception de) { de.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { JFrame jframe = new JFrame(); jframe.setSize(500, 200);// w ww .j a v a 2 s . c om jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextPane jTextPane = new JTextPane(); jTextPane.setEditorKit(new HTMLEditorKit()); JButton btn = new JButton("Print"); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { jTextPane.setContentType("text/html"); boolean done = jTextPane.print(); if (done) { System.out.println("Printing is done"); } else { System.out.println("Error while printing"); } } catch (Exception pex) { pex.printStackTrace(); } } }); jframe.add(btn, BorderLayout.SOUTH); jframe.add(jTextPane); jframe.setVisible(true); }