List of usage examples for java.lang Throwable printStackTrace
public void printStackTrace()
From source file:czlab.xlib.CU.java
public static void main(String[] args) { try {/* w ww . j a va2 s .co m*/ /* "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" "`~!@#$%^&*()-_+={}[]|\:;',.<>?/'" */ // String script = "(fn [_] {:a 1} )"; // IFn fn = (IFn)RT.var("clojure.core", "eval").invoke(RT.var("clojure.core","read-string").invoke(script)); // Object obj = fn.invoke("Hello"); // Map<?,?> m= (Map<?,?>)obj; // Keyword k= Keyword.intern("a"); // System.out.println("obj= " + m.get(k)); //System.out.println(shuffle("0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz")); // URLCodec cc = new URLCodec("utf-8"); // System.out.println(cc.encode("hello\u0000world")); // String[] rc= StringUtils.split(",;,;,;", ",;"); String rc = new Locale("en").toString(); rc = null; } catch (Throwable t) { t.printStackTrace(); } }
From source file:it.cnr.icar.eric.client.admin.AdminShellUtilityTest.java
public static void main(String[] args) { try {//from ww w. j a v a 2 s .c o m junit.textui.TestRunner.run(suite()); } catch (Throwable t) { System.out.println("Throwable: " + t.getClass().getName() + " Message: " + t.getMessage()); t.printStackTrace(); } }
From source file:net.hydromatic.foodbench.Main.java
/** Main method. */ public static void main(String[] args) { try {/*from w ww . ja va 2 s . c om*/ // E.g. Main -Dtest.ids=10,20-30,-23 final RangeSet<Integer> idSet = parseInts(System.getProperty("foodbench.ids")); final boolean verbose = Boolean.parseBoolean(System.getProperty("foodbench.verbose")); Main main = new Main(idSet, verbose); switch (1) { case 0: main.run("jdbc:mysql://localhost?user=foodmart&password=foodmart", "foodmart", "com.mysql.jdbc.Driver"); break; case 1: main.run("jdbc:optiq:model=inline:" + OPTIQ_MODEL, "FOODMART_CLONE", null); break; } } catch (Throwable e) { e.printStackTrace(); } }
From source file:fedora.server.utilities.ServerUtility.java
/** * Command-line entry point to reload policies. Takes 3 args: protocol user * pass/*from w ww .j ava2s .c o m*/ */ public static void main(String[] args) { initLogging(); if (args.length == 3) { try { reloadPolicies(args[0], args[1], args[2]); System.out.println("SUCCESS: Policies have been reloaded"); System.exit(0); } catch (Throwable th) { th.printStackTrace(); System.err.println("ERROR: Reloading policies failed; see above"); System.exit(1); } } else { System.err.println("ERROR: Three arguments required: " + "http|https username password"); System.exit(1); } }
From source file:example.Listener.java
public static void main(String[] args) throws Exception { String user = env("ACTIVEMQ_USER", "admin"); String password = env("ACTIVEMQ_PASSWORD", "password"); String host = env("ACTIVEMQ_HOST", "localhost"); int port = Integer.parseInt(env("ACTIVEMQ_PORT", "1883")); final String destination = arg(args, 0, "/topic/event"); MQTT mqtt = new MQTT(); mqtt.setHost(host, port);/* ww w . j a v a2 s.c o m*/ mqtt.setUserName(user); mqtt.setPassword(password); final CallbackConnection connection = mqtt.callbackConnection(); connection.listener(new org.fusesource.mqtt.client.Listener() { long count = 0; long start = System.currentTimeMillis(); public void onConnected() { } public void onDisconnected() { } public void onFailure(Throwable value) { value.printStackTrace(); System.exit(-2); } public void onPublish(UTF8Buffer topic, Buffer msg, Runnable ack) { String body = msg.utf8().toString(); if ("SHUTDOWN".equals(body)) { long diff = System.currentTimeMillis() - start; System.out.println(String.format("Received %d in %.2f seconds", count, (1.0 * diff / 1000.0))); connection.disconnect(new Callback<Void>() { @Override public void onSuccess(Void value) { System.exit(0); } @Override public void onFailure(Throwable value) { value.printStackTrace(); System.exit(-2); } }); } else { if (count == 0) { start = System.currentTimeMillis(); } if (count % 1000 == 0) { System.out.println(String.format("Received %d messages.", count)); } count++; } ack.run(); } }); connection.connect(new Callback<Void>() { @Override public void onSuccess(Void value) { Topic[] topics = { new Topic(destination, QoS.AT_LEAST_ONCE) }; connection.subscribe(topics, new Callback<byte[]>() { public void onSuccess(byte[] qoses) { } public void onFailure(Throwable value) { value.printStackTrace(); System.exit(-2); } }); } @Override public void onFailure(Throwable value) { value.printStackTrace(); System.exit(-2); } }); // Wait forever.. synchronized (Listener.class) { while (true) Listener.class.wait(); } }
From source file:TaskQueueSample.java
public static void main(String[] args) { if (args.length != 4) { System.out.println("Insuficient arguments"); printUsage();//from w ww. j a v a 2s .c o m System.exit(1); } else if (!parseParams(args)) { printUsage(); System.exit(1); } try { run(); // success! return; } catch (IOException e) { System.err.println(e.getMessage()); } catch (Throwable t) { t.printStackTrace(); } System.exit(1); }
From source file:com.google.api.services.samples.calendar.cmdline.CalendarSample.java
public static void main(String[] args) { try {/*from w w w. j a v a 2 s . c om*/ // initialize the transport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); // initialize the data store factory dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR); // authorization Credential credential = authorize(); // set up global Calendar instance client = new Calendar.Builder(httpTransport, JSON_FACTORY, credential) .setApplicationName(APPLICATION_NAME).build(); System.out.println(client.getServicePath()); System.out.println(client.getBaseUrl()); System.out.println(client.getRootUrl()); System.out.println( client.calendars().get("14tgse4ldpicq5o4pq2metp460@group.calendar.google.com").values()); System.out.println("Fields:" + client.calendars().get("14tgse4ldpicq5o4pq2metp460@group.calendar.google.com").getFields()); List<CalendarListEntry> object = (List<CalendarListEntry>) client.calendarList().list().execute() .get("items"); for (CalendarListEntry aCalendar : object) { System.out.println(aCalendar.getSummary() + "::" + aCalendar.getId() + "::" + aCalendar.getClass() + "::" + aCalendar); } System.out.println("Items: \t\t" + object); for (Object o : client.calendarList().list().execute().keySet()) { System.out.println(":::" + o); // com.google.api.client.util.Data l; } for (Object o : client.calendars().get("14tgse4ldpicq5o4pq2metp460@group.calendar.google.com") .entrySet()) { System.out.println(o); } System.out.println(client.settings().list().size()); System.out.println(client.calendarList().list().size()); // assertEquals(0, client.calendarList().list().size()); // assertEquals(0, client.events().list().size()); for (Object o : client.calendarList().list().keySet()) { System.out.println(o); } System.out.println("Success! Now add code here."); } catch (IOException e) { System.err.println(e.getMessage()); } catch (Throwable t) { t.printStackTrace(); } System.exit(1); }
From source file:models.logic.CipherDecipher.java
public static void main(String[] args) { try {/*from www . j av a2 s .com*/ System.out.println("Hash original: " + utils.HashGenerator.generateSHA512("originalFiles/original")); //Gerando o par KeyPair kp = publicPrivateKeyGenerator(); User user = new User("Nome", "a@a.com", kp.getPublic(), kp.getPrivate()); //Gerando a chave randomica SecretKey key = generateKey(); //Encriptando o arquivo FileInputStream fis = new FileInputStream("originalFiles/original"); FileOutputStream fos = new FileOutputStream("encrypted.txt"); encrypt(key, fis, fos); System.out.println("Hash encriptado: " + utils.HashGenerator.generateSHA512("encrypted.txt")); //Salvando a chave em disco keyToFile(key, "key"); //Encriptando a chave com a chave privada FileInputStream fisKey = new FileInputStream("key"); FileOutputStream fosKey = new FileOutputStream("encryptedKey"); encrypt((SecretKey) user.getPrivateKey(), fis, fos); //Decriptando a chave em disco FileInputStream fisKey2 = new FileInputStream("encryptedKey"); FileOutputStream fosKey2 = new FileOutputStream("decryptedKey"); decrypt((SecretKey) user.getPublicKey(), fisKey2, fosKey2); //Zerando a chave e abrindo do arquivo key = null; key = fileToKey("decryptedKey"); //String keyString = keyToString(key); //System.out.println(keyString); //key = null; //key = stringToKey(keyString); FileInputStream fis2 = new FileInputStream("encrypted.txt"); FileOutputStream fos2 = new FileOutputStream("decrypted.txt"); decrypt(key, fis2, fos2); System.out.println("Hash Final: " + utils.HashGenerator.generateSHA512("decrypted.txt")); } catch (Throwable e) { e.printStackTrace(); } }
From source file:it.cnr.icar.eric.client.xml.registry.SecureSessionPerformanceTest.java
public static void main(String[] args) { System.out.println("Get into the program...\n"); try {/*from ww w . ja va2s . c o m*/ TestRunner.run(suite()); } catch (Throwable t) { System.out.println("Throwable: " + t.getClass().getName() + " Message: " + t.getMessage()); t.printStackTrace(); } }
From source file:caarray.client.examples.grid.DownloadArrayDesignForHybridization.java
public static void main(String[] args) { DownloadArrayDesignForHybridization downloader = new DownloadArrayDesignForHybridization(); try {/*from w w w . java 2 s . c om*/ client = new CaArraySvc_v1_0Client(BaseProperties.getGridServiceUrl()); System.out.println("Downloading array design file for hybridization " + HYBRIDIZATION_NAME + " in " + EXPERIMENT_TITLE + "..."); downloader.download(); } catch (Throwable t) { System.out.println("Error while downloading array design file."); t.printStackTrace(); } }