List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:Main.java
public static void main(String args[]) { try {//from w w w .j a v a 2 s .com int port = 80; DatagramSocket ds = new DatagramSocket(port); while (true) { byte buffer[] = new byte[BUFSIZE]; DatagramPacket dp = new DatagramPacket(buffer, buffer.length, InetSocketAddress.createUnresolved("google.com", 8080)); ds.receive(dp); String str = new String(dp.getData()); System.out.println(str); } } catch (Exception e) { e.printStackTrace(); } }
From source file:SimpleAnnotationsWithHyperLinkInAnImagePDF.java
public static void main(String[] args) { Document document1 = new Document(PageSize.A4, 10, 10, 10, 10); try {/*from w ww .j a va 2 s .c o m*/ PdfWriter writer1 = PdfWriter.getInstance(document1, new FileOutputStream("SimpleAnnotationsWithHyperLinkInAnImagePDF.pdf")); writer1.setPdfVersion(PdfWriter.VERSION_1_5); document1.open(); Annotation a = new Annotation(250f, 400f, 350f, 500f, "http://www.java2s.com"); document1.add(a); Image image = Image.getInstance("logo.png"); image.setAnnotation(a); document1.add(image); } catch (Exception de) { de.printStackTrace(); } document1.close(); }
From source file:Main.java
public static void main(String[] args) { try {// w w w . j a va2 s .c om PipedWriter writer = new PipedWriter(); PipedReader reader = new PipedReader(writer); // connect the reader and the writer reader.connect(writer); writer.write(70); writer.write(71); // check if reader is ready to read System.out.println(reader.ready()); // print the char array for (int i = 0; i < 2; i++) { System.out.println("" + (char) reader.read()); } reader.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:TableSpacingBeforePDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4); try {// ww w . ja v a 2 s. c om PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("TableSpacingBeforePDF.pdf")); document.open(); PdfPTable table = new PdfPTable(3); PdfPCell cell = new PdfPCell(new Paragraph("header with colspan 3")); cell.setColspan(3); table.addCell(cell); table.setSpacingBefore(150f); document.add(table); document.add(table); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:PageFooterPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 70, 70); try {//from w w w . j av a 2 s . c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("PageFooterPDF.pdf")); document.open(); document.add(new Paragraph("text")); Rectangle page = document.getPageSize(); PdfPTable foot = new PdfPTable(1); foot.addCell("Page 1"); foot.setTotalWidth(page.width() - document.leftMargin() - document.rightMargin()); foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(), writer.getDirectContent()); document.close(); } catch (Exception de) { de.printStackTrace(); } }
From source file:Main.java
public static void main(String args[]) { try {/*from ww w . j ava2s . c o m*/ int port = 80; DatagramSocket ds = new DatagramSocket(port); while (true) { byte buffer[] = new byte[BUFSIZE]; DatagramPacket dp = new DatagramPacket(buffer, 0, buffer.length, InetAddress.getByName("google.com"), 8080); ds.receive(dp); String str = new String(dp.getData()); System.out.println(str); } } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {/* ww w. ja v a 2 s . c o m*/ // create a new OutputStreamWriter OutputStream os = new FileOutputStream("test.txt"); OutputStreamWriter writer = new OutputStreamWriter(os); // create a new FileInputStream to read what we write FileInputStream in = new FileInputStream("test.txt"); // write something in the file writer.write(70); // flush the stream writer.flush(); // read what we write System.out.println((char) in.read()); writer.close(); os.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:PageHeaderPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 70, 70); try {/*from w ww. j a v a 2s. c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("PageHeaderPDF.pdf")); document.open(); document.add(new Paragraph("text")); Rectangle page = document.getPageSize(); PdfPTable head = new PdfPTable(1); head.addCell("Page 1"); head.setTotalWidth(page.width() - document.leftMargin() - document.rightMargin()); head.writeSelectedRows(0, -1, document.leftMargin(), page.height() - document.topMargin() + head.getTotalHeight(), writer.getDirectContent()); document.close(); } catch (Exception de) { de.printStackTrace(); } }
From source file:org.jupiter.example.spring.JupiterClient.java
public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:spring-consumer.xml"); ServiceTest service = ctx.getBean(ServiceTest.class); try {//from ww w. j a v a 2 s . co m ServiceTest.ResultClass result1 = service.sayHello(); System.out.println(result1); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.ebay.recommendations.LatestVersion.java
/** * @param args/*from ww w . j a va 2s . c o m*/ */ public static void main(String[] args) { // TODO Auto-generated method stub HttpClient client = new HttpClient(); String fullUri = "https://svcs.ebay.com/services/selling/listingrecommendation/latestVersion"; HttpMethod method = new GetMethod(fullUri); // REPLACE YOUR TOKEN IN THE <YOUR_TOKEN_HERE> PLACE HOLDER method.addRequestHeader("Authorization", "TOKEN <YOUR_TOKEN_HERE>"); method.addRequestHeader("Accept", "application/xml"); try { client.executeMethod(method); String response = method.getResponseBodyAsString(); System.out.println(response); } catch (Exception e) { e.printStackTrace(); } }