List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:MainClass.java
public static void main(String[] args) throws Exception { LineNumberReader lineCounter = new LineNumberReader(new InputStreamReader(System.in)); String nextLine = null;/* w ww.j a va2 s. c o m*/ System.out.println("Type any text and press return. Type 'exit' to quit the program."); try { while ((nextLine = lineCounter.readLine()).indexOf("exit") == -1) { if (nextLine == null) break; System.out.print(lineCounter.getLineNumber()); System.out.print(": "); System.out.println(nextLine); } } catch (Exception done) { done.printStackTrace(); } }
From source file:Copy.java
public static void main(String[] args) { FileChannel in = null;//from w ww . j a v a 2 s . c o m FileChannel out = null; if (args.length < 2) { System.out.println("Usage: java Copy <from> <to>"); System.exit(1); } try { in = new FileInputStream(args[0]).getChannel(); out = new FileOutputStream(args[1]).getChannel(); out.transferFrom(in, 0L, (int) in.size()); } catch (Exception e) { e.printStackTrace(); } }
From source file:FormFillPDF.java
public static void main(String[] args) { try {//from w w w . j av a 2s . c o m PdfReader reader = new PdfReader("SimpleRegistrationForm.pdf"); // filling in the form PdfStamper stamp1 = new PdfStamper(reader, new FileOutputStream("FormFillPDF.pdf")); AcroFields form1 = stamp1.getAcroFields(); form1.setField("name", "your name"); form1.setField("address", "Your Address"); form1.setField("postal_code", "1111"); form1.setField("email", "email"); stamp1.close(); } catch (Exception de) { de.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {//from w w w .j av a 2 s . c o m String[] cmdArray = new String[2]; // first argument is the program to open cmdArray[0] = "notepad.exe"; // data.txt is the file to open with notepad cmdArray[1] = "data.txt"; // create a process and execute cmdArray Runtime runTime = Runtime.getRuntime(); Process process = runTime.exec(cmdArray); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:SimpleAnnotationsPDF.java
public static void main(String[] args) { Document document1 = new Document(PageSize.A4, 10, 10, 10, 10); try {// w w w . j a v a2 s. c o m PdfWriter writer1 = PdfWriter.getInstance(document1, new FileOutputStream("SimpleAnnotationsPDF.pdf")); writer1.setPdfVersion(PdfWriter.VERSION_1_5); document1.open(); Annotation a1 = new Annotation("authors", "Text for an annotation", 250f, 700f, 350f, 800f); document1.add(a1); } catch (Exception de) { de.printStackTrace(); } document1.close(); }
From source file:de.oth.keycloak.CreateConfigSchema.java
public static void main(String[] args) { ObjectMapper mapper = new ObjectMapper(); try {/*from w w w. j a va 2 s . c om*/ JsonSchema schema = mapper.generateJsonSchema(RealmsConfig.class); String s = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema); System.out.println(s); } catch (Exception e) { e.printStackTrace(); } }
From source file:SpaceWordRatioNO_SPACE_CHAR_RATIO.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 350, 50, 50); try {//from w w w .j a v a 2s .c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SpaceWordRatioNO_SPACE_CHAR_RATIO.pdf")); document.open(); String text = "This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph."; Paragraph p = new Paragraph(text); document.add(p); document.newPage(); writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO); document.add(p); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:MainClass.java
public static void main(String[] args) { try {/*from w w w .j a v a 2 s. co m*/ test(); } catch (Exception e) { e.printStackTrace(); } }
From source file:SpaceWordRatioSPACE_CHAR_RATIO_DEFAULT.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 350, 50, 50); try {//ww w. j av a 2 s . com PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SpaceWordRatioSPACE_CHAR_RATIO_DEFAULT.pdf")); document.open(); String text = "This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph."; Paragraph p = new Paragraph(text); document.add(p); document.newPage(); writer.setSpaceCharRatio(PdfWriter.SPACE_CHAR_RATIO_DEFAULT); document.add(p); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:Main.java
public static void main(String[] args) { try {//w ww .j av a 2 s . com // create a new process Process p = Runtime.getRuntime().exec("notepad.exe"); // get the error stream of the process and print it InputStream error = p.getErrorStream(); for (int i = 0; i < error.available(); i++) { System.out.println(error.read()); } // wait for 10 seconds and then destroy the process Thread.sleep(10000); p.destroy(); } catch (Exception ex) { ex.printStackTrace(); } }