List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:OnEndPageEventPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 70, 70); try {//from w ww. j av a 2 s . c om PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("OnEndPageEventPDF.pdf")); writer.setPageEvent(new OnEndPageEventPDF()); document.open(); document.add(new Paragraph("text")); document.close(); } catch (Exception de) { de.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {// w w w . j a v a2s . c om PrintWriter pw = new PrintWriter("c:/text.txt"); // append chars pw.append('H'); pw.append('e'); pw.append('l'); pw.append('l'); pw.append('o'); // flush the writer pw.flush(); pw.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {/*from w w w .j a v a 2 s. com*/ File dir = new File("C:/"); String[] envArray = new String[2]; envArray[0] = ""; envArray[1] = ""; // create a process and execute notepad.exe and currect environment Runtime runTime = Runtime.getRuntime(); Process process = runTime.exec("notepad.exe", envArray, dir); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:ArabicTextPDF.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 2s. co m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ArabicTextPDF.pdf")); document.open(); java.awt.Font font = new java.awt.Font("arial", 0, 18); PdfContentByte cb = writer.getDirectContent(); java.awt.Graphics2D g2 = cb.createGraphicsShapes(PageSize.A4.width(), PageSize.A4.height()); g2.setFont(font); g2.drawString("\u0634\u0627\u062f\u062c\u0645\u0647\u0648\u0645\u0646", 100, 100); g2.dispose(); document.close(); } catch (Exception de) { de.printStackTrace(); } }
From source file:Message.java
public static void main(String[] args) { try {/*w ww .j a v a 2 s.co m*/ Message p = new Message(); // register Message as shutdown hook Runtime runTime = Runtime.getRuntime(); runTime.addShutdownHook(p); // remove the hook runTime.removeShutdownHook(p); System.out.println("Program is closing..."); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {//w w w . j a v a2s. co m PrintWriter pw = new PrintWriter(System.out, true); // append chars pw.append('H'); pw.append('e'); pw.append('l'); pw.append('l'); pw.append('o'); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:OpenApplicationPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {//from w ww .j a v a2s . c om PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("OpenApplicationPDF.pdf")); document.open(); String application = "notepad.exe"; Paragraph p = new Paragraph(new Chunk("Click to open " + application) .setAction(new PdfAction(application, null, null, null))); document.add(p); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:Main.java
public static void main(String[] args) { try {//from www.j a v a 2s . co m PrintWriter pw = new PrintWriter(System.out); // append chars pw.append('H'); pw.append('e'); pw.append('l'); pw.append('l'); pw.append('o'); // flush the writer pw.flush(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {//w ww . ja v a2s. c om // create a new process System.out.println("Creating Process..."); Process p = Runtime.getRuntime().exec("notepad.exe"); // wait 10 seconds System.out.println("Waiting..."); Thread.sleep(10000); // kill the process p.destroy(); System.out.println("Process destroyed."); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {/*from w w w .ja v a 2s . c o m*/ PrintWriter pw = new PrintWriter(new File("c:/text.txt"), "ACSII"); // append chars pw.append('H'); pw.append('e'); pw.append('l'); pw.append('l'); pw.append('o'); // flush the writer pw.flush(); pw.close(); } catch (Exception ex) { ex.printStackTrace(); } }