List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:SimpleAnnotationsAddAnnotationWithoutSpecifyingCoordinates.java
public static void main(String[] args) { Document document1 = new Document(PageSize.A4, 10, 10, 10, 10); try {//from ww w . ja v a2 s. co m PdfWriter writer1 = PdfWriter.getInstance(document1, new FileOutputStream("SimpleAnnotationsAddAnnotationWithoutSpecifyingCoordinates.pdf")); writer1.setPdfVersion(PdfWriter.VERSION_1_5); document1.open(); document1.add(new Annotation("blahblah", "Adding an annotation without specifying coordinates")); } catch (Exception de) { de.printStackTrace(); } document1.close(); }
From source file:SimpleAnnotationsWithMpegMoviePDF.java
public static void main(String[] args) { Document document1 = new Document(PageSize.A4, 10, 10, 10, 10); try {//from w w w . j av a 2 s. c om PdfWriter writer1 = PdfWriter.getInstance(document1, new FileOutputStream("SimpleAnnotationsWithMpegMoviePDF.pdf")); writer1.setPdfVersion(PdfWriter.VERSION_1_5); document1.open(); Annotation a = new Annotation(100f, 700f, 200f, 800f, "cards.mpg", "video/mpeg", true); document1.add(a); } catch (Exception de) { de.printStackTrace(); } document1.close(); }
From source file:MergingTwoPDFToOne.java
public static void main(String[] args) { try {//from w w w. j ava 2 s .c om PdfReader reader = new PdfReader("YourOwnPDF.pdf"); PdfStamper stamp = new PdfStamper(reader, new FileOutputStream("TwoPDF.pdf")); PdfContentByte under; PdfReader reader2 = new PdfReader("AnotherPDF.pdf"); under = stamp.getUnderContent(1); under.addTemplate(stamp.getImportedPage(reader2, 1), 1, 0, 0, 1, 0, 0); stamp.close(); } catch (Exception de) { de.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {//from w w w .j a va 2 s. c om // create a new process Process p = Runtime.getRuntime().exec("notepad.exe"); // get the input stream of the process and print it InputStream in = p.getInputStream(); for (int i = 0; i < in.available(); i++) { System.out.println(in.read()); } // wait for 10 seconds and then destroy the process Thread.sleep(10000); p.destroy(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:AnnotatedImageHyperLink.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {/*w w w .j a v a 2 s . c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("AnnotatedImageHyperLink.pdf")); document.open(); Image png = Image.getInstance("logo.png"); png.setAnnotation(new Annotation(0, 0, 0, 0, "http://www.java2s.com")); png.setAbsolutePosition(100f, 550f); document.add(png); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:DeleteRecordsUsingPreparedStatement.java
public static void main(String[] args) throws Exception { Connection conn = null;//from w ww .j a va 2 s .co m PreparedStatement pstmt = null; try { conn = getConnection(); String query = "delete from tableName"; pstmt = conn.prepareStatement(query); pstmt.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { pstmt.close(); conn.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); try {//ww 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]); } pis.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:AnnotatedImagePDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {/*from w ww .j a v a 2 s.c o m*/ PdfWriter.getInstance(document, new FileOutputStream("AnnotatedImagePDF.pdf")); document.open(); Image jpeg = Image.getInstance("logo.png"); jpeg.setAnnotation(new Annotation("picture", "This is the logo", 0, 0, 0, 0)); jpeg.setAbsolutePosition(100f, 550f); document.add(jpeg); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:Main.java
public static void main(String args[]) { try {/*www .j a v a2s . c om*/ int port = 80; DatagramSocket ds = new DatagramSocket(port); byte buffer[] = new byte[BUFSIZE]; while (true) { DatagramPacket dp = new DatagramPacket(buffer, buffer.length); dp.setPort(9090); } } catch (Exception e) { e.printStackTrace(); } }
From source file:MainClass.java
public static void main(String args[]) { try {/*from w ww. ja v a2 s. c om*/ URL url = new URL("http://www.java2s.com"); // Obtain output stream InputStream is = url.openStream(); // Read and display data from url byte buffer[] = new byte[1024]; int i; while ((i = is.read(buffer)) != -1) { System.out.write(buffer, 0, i); } } catch (Exception e) { e.printStackTrace(); } }