List of usage examples for java.lang Exception getMessage
public String getMessage()
From source file:AddingRectangleToColumnPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from www. j av a 2s .c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("AddingRectangleToColumnPDF.pdf")); document.open(); BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); Font font = new Font(bf, 11, Font.NORMAL); Phrase col1 = new Phrase(15, "col1", font); Phrase col2 = new Phrase(15, "col2", font); Phrase col3 = new Phrase(15, "col3", font); for (int i = 0; i < 40; i++) { col1.add("col 1\n"); col2.add("col 2\n"); col3.add("col 3\n"); } PdfContentByte cb = writer.getDirectContent(); ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(col1, 60, 300, 100, 300 + 28 * 15, 15, Element.ALIGN_CENTER); ct.go(); ct.setSimpleColumn(col2, 105, 300, 150, 300 + 28 * 15, 15, Element.ALIGN_RIGHT); ct.go(); cb.rectangle(53, 295, 52, 8 + 28 * 15); cb.stroke(); ct.setSimpleColumn(col3, 160, 300, 500, 300 + 28 * 15, 15, Element.ALIGN_LEFT); ct.go(); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:hackathon.Hackathon.java
/** * @param args the command line arguments *///from w w w .ja v a 2 s . c o m public static void main(String[] args) { // TODO code application logic here HttpClient httpclient = HttpClients.createDefault(); try { URIBuilder builder = new URIBuilder( "https://westus.api.cognitive.microsoft.com/emotion/v1.0/recognize"); URI uri = builder.build(); HttpPost request = new HttpPost(uri); request.setHeader("Content-Type", "application/json"); request.setHeader("Ocp-Apim-Subscription-Key", "3532e4ff429c4cce9baa783451db8b3b"); // Request body String url = "https://s-media-cache-ak0.pinimg.com/564x/af/8b/47/af8b47d56ded6952fa8ebfdcf7e87f43.jpg"; StringEntity reqEntity = new StringEntity( "{'url' : 'https://s-media-cache-ak0.pinimg.com/564x/af/8b/47/af8b47d56ded6952fa8ebfdcf7e87f43.jpg'}"); request.setEntity(reqEntity); HttpResponse response = httpclient.execute(request); HttpEntity entity = response.getEntity(); if (entity != null) { System.out.println(EntityUtils.toString(entity)); } } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:dm.meta.MetaTest.java
public static void main(String[] args) { MetaTest modelTest = null;/*from www . ja va 2 s .c o m*/ try { modelTest = new MetaTest(); modelTest.test(); modelTest.close(); } catch (Exception e) { log.error("Error in MetaTest.main: " + e.getMessage()); modelTest.close(); } }
From source file:SetupJNDIDataSource.java
public static void main(String args[]) { try {/*from w ww . ja v a2 s .c om*/ startRegistry(); ConnectionPoolDataSource dataSource = new MysqlConnectionPoolDataSource(); dataSource.setUser("username"); dataSource.setPassword("password"); dataSource.setServerName("localhost"); dataSource.setPort(3306); dataSource.setDatabaseName("databasename"); InitialContext context = createContext(); context.rebind("HrDS", dataSource); } catch (Exception e) { System.out.println("SetupJNDIDataSource err: " + e.getMessage()); e.printStackTrace(); } }
From source file:com.mobius.software.mqtt.performance.runner.ScenarioRunner.java
public static void main(String[] args) { try {/*ww w. j ava 2s . c o m*/ File json = FileUtil.readFile(args[0]); List<ScenarioRequest> requests = parseRequests(json); ScenarioRunner runner = new ScenarioRunner(requests); runner.start(); } catch (Exception e) { logger.error(e.getMessage()); System.exit(0); } }
From source file:com.sm.store.TestStoreClient.java
public static void main(String[] args) { String[] opts = new String[] { "-store", "-url", "-times" }; String[] defaults = new String[] { "store", "localhost:7100", "10" }; String[] paras = getOpts(args, opts, defaults); String store = paras[0];//from www .j a v a 2s . c o m String url = paras[1]; int times = Integer.valueOf(paras[2]); RemotePersistence client = new NTRemoteClientImpl(url, null, store, false); for (int i = 0; i < times; i++) { try { Key key = Key.createKey(i); client.put(key, "times-" + i); Value value = client.get(key); logger.info(value == null ? "null" : value.getData().toString() + " " + value.getVersion()); //value.setVersion( value.getVersion() -1); client.put(key, value); value = client.get(key); logger.info(value == null ? "null" : value.getData().toString() + " " + value.getVersion()); client.put(key, "times-" + i); value = client.get(key); logger.info(value == null ? "null" : value.getData().toString() + " " + value.getVersion()); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } } List<Key> list = client.getKeyList(); logger.info("key size " + list.size()); client.close(); System.exit(0); }
From source file:backtype.storm.security.serialization.BlowfishTupleSerializer.java
/** * Produce a blowfish key to be used in "Storm jar" command *///from w ww . j a v a2s .c om public static void main(String[] args) { try { KeyGenerator kgen = KeyGenerator.getInstance("Blowfish"); SecretKey skey = kgen.generateKey(); byte[] raw = skey.getEncoded(); String keyString = new String(Hex.encodeHex(raw)); System.out.println("storm -c " + SECRET_KEY + "=" + keyString + " -c " + Config.TOPOLOGY_TUPLE_SERIALIZER + "=" + BlowfishTupleSerializer.class.getName() + " ..."); } catch (Exception ex) { LOG.error(ex.getMessage()); ex.printStackTrace(); } }
From source file:backtype.storm.command.list.java
/** * @param args// w w w.jav a 2 s. com */ public static void main(String[] args) { NimbusClient client = null; try { Map conf = Utils.readStormConfig(); client = NimbusClient.getConfiguredClient(conf); if (args.length > 0 && StringUtils.isBlank(args[0]) == false) { String topologyName = args[0]; TopologyInfo info = client.getClient().getTopologyInfoByName(topologyName); System.out.println("Successfully get topology info \n" + Utils.toPrettyJsonString(info)); } else { ClusterSummary clusterSummary = client.getClient().getClusterInfo(); System.out.println("Successfully get cluster info \n" + Utils.toPrettyJsonString(clusterSummary)); } } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); throw new RuntimeException(e); } finally { if (client != null) { client.close(); } } }
From source file:br.gov.lexml.swing.spellchecker.SpellcheckerMain.java
public static void main(String[] args) { try {//from ww w .j a v a2 s . c o m System.out.println("Preparando diretrio"); File baseDir = new File("target/spellchecker"); if (!baseDir.isDirectory()) { baseDir.mkdirs(); } Spellchecker s = SpellcheckerFactory.getInstance().createSpellchecker(baseDir); System.out.println("Hunspell library and dictionary loaded"); String words[] = { "subnutido", "isso", "nao" }; for (int i = 0; i < words.length; i++) { String word = words[i]; if (s.misspelled(word)) { List<String> suggestions = s.suggest(word); print("misspelled: " + word); if (suggestions.isEmpty()) { print("\tNo suggestions."); } else { print("\tTry:"); for (String sug : suggestions) { print(" " + sug); } } println(""); } else { println("ok: " + word); } } } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:SetupJNDIDataSource.java
public static void main(String args[]) { if (args.length < 2) { System.out.println("usage: SetupJNDIDataSource username password"); return;// w w w. java 2 s .c om } try { startRegistry(); ConnectionPoolDataSource dataSource = createDataSource(args[0], args[1]); InitialContext context = createContext(); context.rebind("HrDS", dataSource); } catch (Exception e) { System.out.println("SetupJNDIDataSource err: " + e.getMessage()); e.printStackTrace(); } }