List of usage examples for java.lang Exception printStackTrace
public void printStackTrace()
From source file:org.devware.batch.main.Launcher.java
public static void main(String arg[]) { String[] springConfig = { "org/devware/config/context/readerConfig.xml", "org/devware/config/context/writerConfig.xml", "org/devware/config/context/processorConfig.xml", "org/devware/config/datasource/datasource.xml" }; ApplicationContext context = new ClassPathXmlApplicationContext(springConfig); JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher"); Job job = (Job) context.getBean("ExcelReaderJob"); try {/*from ww w. j av a 2s .co m*/ JobExecution execution = jobLauncher.run(job, new JobParameters()); System.out.println("Exit Status : " + execution.getStatus()); } catch (Exception e) { // e.printStackTrace(); } System.out.println("Done"); }
From source file:test.gov.nih.nci.system.web.client.ProductReadClient.java
public static void main(String[] args) { InputStream is = null;//from w w w . j a va2s . c o m try { if (args == null || args.length != 1) { System.out.println("Usage: RESTFulReadClient <RESTful resource URL>"); return; } String url = args[0]; RESTfulReadClient client = new RESTfulReadClient(); Response response = client.read(url); is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); System.out.println(outputter.outputString(jDoc)); } catch (Exception e) { e.printStackTrace(); } finally { if (is != null) is.close(); } }
From source file:com.cliqset.magicsig.util.KeyTester.java
public static void main(String[] args) { try {/*from www . ja v a 2 s. c o m*/ FileInputStream fis = new FileInputStream(keyFile); BufferedReader reader = new BufferedReader(new InputStreamReader(fis)); String line = null; while ((line = reader.readLine()) != null) { MagicKey key = new MagicKey(line.getBytes("ASCII")); RSASHA256MagicSigAlgorithm alg = new RSASHA256MagicSigAlgorithm(); byte[] sig = alg.sign(data, key); System.out.println(Base64.encodeBase64URLSafeString(sig)); boolean verified = alg.verify(data, sig, key); if (!verified) { System.out.println("FAILED - " + line); } //System.out.println(lineSplit[0] + " " + key.toString(true)); } } catch (Exception e) { e.printStackTrace(); } System.out.println("Done."); }
From source file:com.ibm.rdf.store.sparql11.DB2RDFQuery.java
public static void main(String[] args) { Options options = new Options(); try {/* ww w . j ava 2 s. com*/ // create Options object options.addOption("jdbcurl", true, "jdbc url"); options.addOption("schema", true, "schema name"); options.addOption("kb", true, "knowledge base"); options.addOption("username", true, "db user name"); options.addOption("password", true, "db password"); options.addOption("queryFile", true, "query file"); options.addOption("defaultUnionGraph", false, "default Union Graph semantics"); CommandLineParser parser = new GnuParser(); CommandLine cmd = parser.parse(options, args); boolean defUnion = cmd.hasOption("defaultUnionGraph") ? Boolean.parseBoolean(cmd.getOptionValue("defaultUnionGraph")) : false; DB2TestData data = new DB2TestData(cmd.getOptionValue("jdbcurl"), cmd.getOptionValue("kb"), cmd.getOptionValue("username"), cmd.getOptionValue("password"), cmd.getOptionValue("schemaName"), defUnion); DB2RDFQuery q = new DB2RDFQuery(new DB2Engine(), data); q.executeQuery(cmd.getOptionValue("queryFile")); } catch (Exception e) { e.printStackTrace(); HelpFormatter help = new HelpFormatter(); help.printHelp("DB2RDFQuery", options); } }
From source file:com.moscona.dataSpace.debug.BadLocks.java
public static void main(String[] args) { try {//from ww w .j a v a2 s. co m String lockFile = "C:\\Users\\Admin\\projects\\intellitrade\\tmp\\bad.lock"; FileUtils.touch(new File(lockFile)); FileOutputStream stream = new FileOutputStream(lockFile); // FileInputStream stream = new FileInputStream(lockFile); FileChannel channel = stream.getChannel(); // FileLock lock = channel.lock(0,Long.MAX_VALUE, true); FileLock lock = channel.lock(); stream.write(new UndocumentedJava().pid().getBytes()); stream.flush(); long start = System.currentTimeMillis(); // while (System.currentTimeMillis()-start < 10000) { // Thread.sleep(500); // } lock.release(); stream.close(); File f = new File(lockFile); System.out.println("Before write: " + FileUtils.readFileToString(f)); FileUtils.writeStringToFile(f, "written after lock released"); System.out.println("After write: " + FileUtils.readFileToString(f)); } catch (Exception e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }
From source file:ChapterSectionNewSectionPagePDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {/*from w w w .j a v a 2s .co m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ChapterSectionNewSectionPagePDF.pdf")); writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); document.open(); Font chapterFont = FontFactory.getFont(FontFactory.HELVETICA, 24, Font.NORMAL, new Color(255, 0, 0)); Font sectionFont = FontFactory.getFont(FontFactory.HELVETICA, 20, Font.NORMAL, new Color(0, 0, 255)); Font subsectionFont = FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD, new Color(0, 64, 64)); Paragraph paragraph1 = new Paragraph("text 1"); Paragraph paragraph2 = new Paragraph("text 2"); Paragraph cTitle = new Paragraph("This is a chapter ", chapterFont); Chapter chapter = new Chapter(cTitle, 1); paragraph2.setAlignment(Element.ALIGN_JUSTIFIED); paragraph1.setAlignment(Element.ALIGN_JUSTIFIED); chapter.add(paragraph1); Paragraph sTitle = new Paragraph("This is section 1 in chapter 1", sectionFont); Section section = chapter.addSection(sTitle, 1); section.add(paragraph1); section.add(Chunk.NEXTPAGE); Paragraph subTitle = new Paragraph("This is subsection 1 of section 1", subsectionFont); Section subsection = section.addSection(subTitle, 3); document.add(chapter); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:ChapterSectionSetBookmarkOpenPDF.java
public static void main(String[] args) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {//from www . j av a 2s. co m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ChapterSectionSetBookmarkOpenPDF.pdf")); writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); document.open(); Font chapterFont = FontFactory.getFont(FontFactory.HELVETICA, 24, Font.NORMAL, new Color(255, 0, 0)); Font sectionFont = FontFactory.getFont(FontFactory.HELVETICA, 20, Font.NORMAL, new Color(0, 0, 255)); Font subsectionFont = FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD, new Color(0, 64, 64)); Paragraph paragraph1 = new Paragraph("text 1"); Paragraph paragraph2 = new Paragraph("text 2"); Paragraph cTitle = new Paragraph("This is a chapter ", chapterFont); Chapter chapter = new Chapter(cTitle, 1); paragraph2.setAlignment(Element.ALIGN_JUSTIFIED); paragraph1.setAlignment(Element.ALIGN_JUSTIFIED); chapter.add(paragraph1); Paragraph sTitle = new Paragraph("This is section 1 in chapter 1", sectionFont); Section section = chapter.addSection(sTitle, 1); section.add(paragraph1); section.setBookmarkOpen(false); Paragraph subTitle = new Paragraph("This is subsection 1 of section 1", subsectionFont); Section subsection = section.addSection(subTitle, 3); document.add(chapter); } catch (Exception de) { de.printStackTrace(); } document.close(); }
From source file:com.estafeta.flujos.DemoMain.java
/** * Clase principal del proyecto/* w w w .j a v a 2 s . c om*/ * @param args argumentos de linea de comandos */ public static void main(String[] args) { // init spring context ApplicationContext ctx = new ClassPathXmlApplicationContext(APPLOCATION_CONTEXT_FILE); // get bean from context JmsMessageSender jmsMessageSender = (JmsMessageSender) ctx.getBean(JMS_MESSAGE_SENDER_BEAN_NAME); // send to a code specified destination Queue queue = new ActiveMQQueue(JMS_DESTINATION_NAME); try { ClassLoader classLoader = DemoMain.class.getClassLoader(); FileInputStream fileInputStream = new FileInputStream( classLoader.getResource(MOCK_INPUT_FILE).getFile()); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(fileInputStream, Charset.forName(UTF_8_CHARSET))); String line; while ((line = bufferedReader.readLine()) != null) { jmsMessageSender.send(queue, line); } fileInputStream.close(); } catch (Exception e) { e.printStackTrace(); } // close spring application context ((ClassPathXmlApplicationContext) ctx).close(); }
From source file:edu.stanford.junction.sample.sql.SendQuery.java
public static void main(String[] argv) { try {/*from w w w. j a v a2 s . c o m*/ // todo: same session for client/server System.out.println("Starting the query actor"); ActivityScript activity = new ActivityScript(); XMPPSwitchboardConfig config = new XMPPSwitchboardConfig("prpl.stanford.edu"); JunctionMaker jm = JunctionMaker.getInstance(config); Junction jx = jm.newJunction(activity, new SendQuery()); //Thread.sleep(5000); //callback.terminate(); } catch (Exception e) { e.printStackTrace(); } }
From source file:DemoScrollableResultSet_MySQL.java
public static void main(String[] args) { Connection conn = null;/*from ww w . j a v a 2 s.c o m*/ Statement stmt = null; ResultSet rs = null; try { conn = getConnection(); String query = "select id, name from employees"; stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = stmt.executeQuery(query); // extract data from the ResultSet scroll from top while (rs.next()) { String id = rs.getString(1); String name = rs.getString(2); System.out.println("id=" + id + " name=" + name); } // scroll from the bottom rs.afterLast(); while (rs.previous()) { String id = rs.getString(1); String name = rs.getString(2); System.out.println("id=" + id + " name=" + name); } } catch (Exception e) { e.printStackTrace(); } finally { // release database resources try { rs.close(); stmt.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); } } }