List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:Main.java
public static void main(String[] args) { boolean bool = false; try {// w ww . j a v a 2 s.co m PrintWriter pw = new PrintWriter(System.out); // print a boolean pw.print(true); // change the line pw.println(); // print another boolean pw.print(bool); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:SimpleTableCellPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50); try {//from w ww . j a v a 2s .c o m PdfWriter.getInstance(document, new FileOutputStream("SimpleTableCellPDF.pdf")); document.open(); SimpleTable table = new SimpleTable(); SimpleCell row = new SimpleCell(SimpleCell.ROW); SimpleCell cell = new SimpleCell(SimpleCell.CELL); cell.add(new Paragraph("B")); cell.setWidth(100f); row.add(cell); table.addElement(row); document.add(table); } catch (Exception e) { e.printStackTrace(); } document.close(); }
From source file:SpotColorsGrayPDF.java
public static void main(String[] args) { Document document = new Document(); try {/* ww w. j a v a2 s . c om*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SpotColorsGrayPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfSpotColor spc_g = new PdfSpotColor("PANTONE 100 CV", 0.5f, new GrayColor(0.9f)); cb.setColorStroke(spc_g, .5f); cb.setLineWidth(10f); cb.rectangle(100, 700, 100, 100); cb.stroke(); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "tutorial from java2s.com."; try {/*from w w w. j a v a 2s . c o m*/ PrintWriter pw = new PrintWriter(System.out); // print string pw.print(s); // change the line pw.println(); // print another string pw.print("This is an example."); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:SpotColorsPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from www .j a va2 s. com*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SpotColorsPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfSpotColor spc_cmyk = new PdfSpotColor("PANTONE 280 CV", 0.25f, new CMYKColor(0.9f, .2f, .3f, .1f)); cb.setColorStroke(spc_cmyk, .5f); cb.setLineWidth(10f); cb.rectangle(100, 700, 100, 100); cb.stroke(); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:Main.java
public static void main(String[] args) { try {// w w w. j a v a 2s.c om PipedReader reader = new PipedReader(); PipedWriter writer = new PipedWriter(reader); // connect the reader and the writer writer.connect(reader); writer.write('A'); writer.write('B'); // print what we wrote for (int i = 0; i < 2; i++) { System.out.println((char) reader.read()); } writer.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:BarcodesPLANET.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {// ww w .j ava 2 s. c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("BarcodesPLANET.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); BarcodePostnet codePlanet = new BarcodePostnet(); codePlanet.setCode("50201402356"); codePlanet.setCodeType(Barcode.PLANET); Image imagePlanet = codePlanet.createImageWithBarcode(cb, null, null); document.add(new Phrase(new Chunk(imagePlanet, 0, 0))); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:Main.java
public static void main(String[] args) { try {// w w w. j a va 2 s . com OutputStream os = new FileOutputStream("test.txt"); InputStream is = new FileInputStream("test.txt"); os.write(70); os.write(71); for (int i = 0; i < 2; i++) { System.out.print((char) is.read()); } os.close(); is.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { Object obj1 = "Object"; Object obj2 = 2;//from ww w. j a va 2 s . co m Date date = new Date(); try { PrintWriter pw = new PrintWriter(System.out); // print object pw.print(obj1); // print another object pw.print(obj2); // print a date (it is an object) pw.print(date); pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String args[]) { try {/*from w w w . j ava2 s . 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); ds.receive(dp); String str = new String(dp.getData()); System.out.println(str); } } catch (Exception e) { e.printStackTrace(); } }