List of usage examples for java.lang Exception getMessage
public String getMessage()
From source file:com.liferay.mobile.sdk.SDKBuilder.java
public static void main(String[] args) throws IOException { SDKBuilder builder = new SDKBuilder(); Map<String, String> arguments = builder.parseArguments(args); String[] platforms = arguments.get("platforms").split(","); String url = arguments.get("url"); String[] contexts = arguments.get("contexts").split(","); String packageName = arguments.get("packageName"); String filter = arguments.get("filter"); int portalVersion = Integer.valueOf(arguments.get("portalVersion")); String destination = arguments.get("destination"); try {//from www . j av a2s .c o m builder.build(platforms, url, contexts, packageName, filter, portalVersion, destination); } catch (Exception e) { _log.log(Level.SEVERE, e.getMessage(), e); } }
From source file:testing01.QuickStart.java
public static void main(String[] args) throws Exception { CloseableHttpClient httpclient = HttpClients.createDefault(); String outputFile = "test.html"; String baseWebSite = "http://www.ettoday.net/news/20130802/250478.htm"; try {/*from ww w . j av a 2 s .c om*/ //HttpGet httpGet = new HttpGet(baseWebSite + "cat/politic/r"); HttpGet httpGet = new HttpGet(baseWebSite); CloseableHttpResponse response1 = httpclient.execute(httpGet); // The underlying HTTP connection is still held by the response // object // to allow the response content to be streamed directly from the // network socket. // In order to ensure correct deallocation of system resources // the user MUST call CloseableHttpResponse#close() from a finally // clause. // Please note that if response content is not fully consumed the // underlying // connection cannot be safely re-used and will be shut down and // discarded // by the connection manager. try { System.out.println(response1.getStatusLine()); HttpEntity entity1 = response1.getEntity(); // do something useful with the response body // and ensure it is fully consumed String responseString = EntityUtils.toString(entity1, "UTF-8"); // System.out.println(responseString); Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "UTF8")); out.write(responseString); out.close(); EntityUtils.consume(entity1); System.out.println(baseWebSite + " output to " + outputFile + " successful"); } catch (Exception e) { System.out.println(e.getMessage()); } finally { response1.close(); } /* * HttpPost httpPost = new HttpPost("http://targethost/login"); List * <NameValuePair> nvps = new ArrayList <NameValuePair>(); * nvps.add(new BasicNameValuePair("username", "vip")); nvps.add(new * BasicNameValuePair("password", "secret")); httpPost.setEntity(new * UrlEncodedFormEntity(nvps)); CloseableHttpResponse response2 = * httpclient.execute(httpPost); * * try { System.out.println(response2.getStatusLine()); HttpEntity * entity2 = response2.getEntity(); // do something useful with the * response body // and ensure it is fully consumed * EntityUtils.consume(entity2); } finally { response2.close(); } */ } finally { httpclient.close(); } }
From source file:edu.harvard.med.iccbl.dev.HibernateConsole.java
public static void main(String[] args) { BufferedReader br = null;/*from www .j a v a 2s . c o m*/ try { CommandLineApplication app = new CommandLineApplication(args); app.processOptions(true, false); br = new BufferedReader(new InputStreamReader(System.in)); EntityManagerFactory emf = (EntityManagerFactory) app.getSpringBean("entityManagerFactory"); EntityManager em = emf.createEntityManager(); do { System.out.println("Enter HQL query (blank to quit): "); String input = br.readLine(); if (input.length() == 0) { System.out.println("Goodbye!"); System.exit(0); } try { List list = ((Session) em.getDelegate()).createQuery(input).list(); // note: this uses the Hibernate Session object, to allow HQL (and JPQL) // List list = em.createQuery(input).getResultList(); // note: this JPA method supports JPQL System.out.println("Result:"); for (Iterator iter = list.iterator(); iter.hasNext();) { Object item = iter.next(); // format output from multi-item selects ("select a, b, c, ... from ...") if (item instanceof Object[]) { List<Object> fields = Arrays.asList((Object[]) item); System.out.println(StringUtils.makeListString(fields, ", ")); } // format output from single-item selected ("select a from ..." or "from ...") else { System.out.println("[" + item.getClass().getName() + "]: " + item); } } System.out.println("(" + list.size() + " rows)\n"); } catch (Exception e) { System.out.println("Hibernate Error: " + e.getMessage()); log.error("Hibernate error", e); } System.out.println(); } while (true); } catch (Exception e) { System.err.println("Fatal Error: " + e.getMessage()); e.printStackTrace(); } finally { IOUtils.closeQuietly(br); } }
From source file:de.oth.keycloak.TestRun.java
public static void main(String[] args) { try {//w w w .j a v a 2s. c o m String server = "http://localhost:8888/auth"; String realm = "master"; String user = "keycloak_admin"; String pwd = "k6ycloakAdmin"; String clientStr = "admin-cli"; String secret = null; String initFileStr = "conf/test_init1.json"; File initFile = new File(initFileStr); if (!initFile.isFile()) { URL url = TestRun.class.getClassLoader().getResource(initFileStr); if (url != null) { initFile = new File(url.getFile()); if (!initFile.isFile()) { log.error("init file does not exist: " + initFile); System.exit(1); } } else { log.error("init file does not exist: " + initFile); System.exit(1); } } Keycloak keycloak = (secret == null) ? Keycloak.getInstance(server, realm, user, pwd, clientStr) : Keycloak.getInstance(server, realm, user, pwd, clientStr, secret); ObjectMapper mapper = new ObjectMapper(); RealmsConfig realmsConfig = mapper.readValue(initFile, RealmsConfig.class); if (realmsConfig != null) { List<RealmConfig> realmList = realmsConfig.getRealms(); if (realmList == null || realmList.isEmpty()) { log.error("no realms config found 1"); return; } for (RealmConfig realmConf : realmList) { InitKeycloakServer.addRealm(keycloak, realmConf); } } else log.error("no realms config found 2"); } catch (Exception e) { log.error(e.getClass().getName() + ": " + e.getMessage()); e.printStackTrace(); System.exit(1); } }
From source file:net.poemerchant.tools.RawAnalysisTool.java
public static void main(String[] args) throws Exception { ElasticSearch.start();// w w w . j av a 2 s . co m String index = "rawanalysis"; String type = "items9"; List<String> shopUrls = shopUrls(); for (String url : shopUrls) { logger.info("Scrapping shop: " + url); try { scrapeAndSaveShop(index, type, url); } catch (Exception e) { logger.info("error caught for " + url + ". err msg: " + e.getMessage()); } } ElasticSearch.shutdown(); }
From source file:com.genentech.chemistry.openEye.apps.SDFRingSystemExtractor.java
/** * @param args/*from w ww.j a v a 2 s . c o m*/ */ public static void main(String... args) throws IOException { // create command line Options object Options options = new Options(); Option opt = new Option(OPT_INFILE, true, "input file oe-supported"); opt.setRequired(true); options.addOption(opt); opt = new Option(OPT_OUTFILE, true, "output file oe-supported"); opt.setRequired(false); options.addOption(opt); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.err.println(e.getMessage()); exitWithHelp(options); } args = cmd.getArgs(); if (cmd.hasOption("d")) { System.err.println("Start debugger and press return:"); new BufferedReader(new InputStreamReader(System.in)).readLine(); } String inFile = cmd.getOptionValue(OPT_INFILE); String outFile = cmd.getOptionValue(OPT_OUTFILE); SDFRingSystemExtractor extractor = new SDFRingSystemExtractor(outFile); extractor.run(inFile); extractor.close(); }
From source file:com.linkedin.pinot.tools.RealtimeQuickStart.java
public static void main(String[] args) { RealtimeQuickStart rst = new RealtimeQuickStart(); try {//from w w w . java2s.c om rst.execute(); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
From source file:course.reference.ReferenceTest.java
public static void main(String[] args) { ReferenceTest referenceTest = null;/* w w w. j a va 2s . c o m*/ try { referenceTest = new ReferenceTest(); if (false) { referenceTest.initReference(); } referenceTest.test(); } catch (Exception e) { log.error("Error in ReferenceTest.main: " + e.getMessage()); } finally { referenceTest.end(); } }
From source file:com.github.r351574nc3.amex.assignment1.App.java
public static void main(final String... args) { if (args.length < 1) { printUsage();/*w w w. j av a 2s . c o m*/ System.exit(0); } final Options options = new Options(); options.addOption(OptionBuilder.withArgName("output").hasArg(true).withDescription("Path for CSV output") .create("o")); options.addOption( OptionBuilder.withArgName("input").hasArg(true).withDescription("Path for CSV input").create("i")); final CommandLineParser parser = new BasicParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.out.println(e.getMessage()); printUsage(); System.exit(0); } if ((cmd.hasOption('o') && cmd.hasOption('i')) || !(cmd.hasOption('o') || cmd.hasOption('i')) || (cmd.hasOption('o') && cmd.getArgs().length < 1)) { printUsage(); System.exit(0); } if (cmd.hasOption('o') && cmd.getArgs().length > 0) { final String outputName = cmd.getOptionValue("o"); final int iterations = Integer.parseInt(cmd.getArgs()[cmd.getArgs().length - 1]); new App().run(new File(outputName), iterations); } else if (cmd.hasOption('i')) { final String inputName = cmd.getOptionValue("i"); new App().run(new File(inputName)); } System.exit(0); }
From source file:com.mycompany.asyncreq.MainApp.java
public static void main(String[] args) throws InterruptedException, ExecutionException, IOException { URIBuilder builder = new URIBuilder(); builder.setScheme("http").setHost("comtrade.un.org").setPath("/api/get").setParameter("max", "50000") .setParameter("type", "C").setParameter("freq", "M").setParameter("px", "HS") .setParameter("ps", "2014").setParameter("r", "804").setParameter("p", "112") .setParameter("rg", "All").setParameter("cc", "All").setParameter("fmt", "json"); URI requestURL = null;/*from w w w . j ava2s . co m*/ try { requestURL = builder.build(); } catch (URISyntaxException use) { } ExecutorService threadpool = Executors.newFixedThreadPool(2); Async async = Async.newInstance().use(threadpool); final Request request = Request.Get(requestURL); try { Future<Content> future = async.execute(request, new FutureCallback<Content>() { @Override public void failed(final Exception e) { System.out.println(e.getMessage() + ": " + request); } @Override public void completed(final Content content) { System.out.println("Request completed: " + request); System.out.println("Response:\n" + content.asString()); } @Override public void cancelled() { } }); } catch (Exception e) { System.out.println("Job threw exception: " + e.getCause()); } }