Example usage for java.lang Exception toString

List of usage examples for java.lang Exception toString

Introduction

In this page you can find the example usage for java.lang Exception toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.microsoft.azure.servicebus.samples.topicsgettingstarted.TopicsGettingStarted.java

public static void main(String[] args) {

    System.exit(runApp(args, (connectionString) -> {
        TopicsGettingStarted app = new TopicsGettingStarted();
        try {/*from   www.j  a  v  a  2 s  .  c  om*/
            app.run(connectionString);
            return 0;
        } catch (Exception e) {
            System.out.printf("%s", e.toString());
            return 1;
        }
    }));
}

From source file:com.microsoft.azure.servicebus.samples.receiveloop.ReceiveLoop.java

public static void main(String[] args) {

    System.exit(runApp(args, (connectionString) -> {
        ReceiveLoop app = new ReceiveLoop();
        try {/*from  w w  w. ja v a2s . co  m*/
            app.run(connectionString);
            return 0;
        } catch (Exception e) {
            System.out.printf("%s", e.toString());
            return 1;
        }
    }));
}

From source file:com.microsoft.azure.servicebus.samples.messagebrowse.MessageBrowse.java

public static void main(String[] args) {

    System.exit(runApp(args, (connectionString) -> {
        MessageBrowse app = new MessageBrowse();
        try {//from   w  w w.ja v  a 2 s.  c  o m
            app.run(connectionString);
            return 0;
        } catch (Exception e) {
            System.out.printf("%s", e.toString());
            return 1;
        }
    }));
}

From source file:GenSig.java

public static void main(String[] args) {

    /* Generate a DSA signature */

    if (args.length != 1) {
        System.out.println("Usage: GenSig nameOfFileToSign");
    } else//  ww  w.  j a  v a 2  s.  co m
        try {

            /* Generate a key pair */

            KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA", "SUN");
            SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");

            keyGen.initialize(1024, random);

            KeyPair pair = keyGen.generateKeyPair();
            PrivateKey priv = pair.getPrivate();
            PublicKey pub = pair.getPublic();

            /*
             * Create a Signature object and initialize it with the private
             * key
             */

            Signature dsa = Signature.getInstance("SHA1withDSA", "SUN");

            dsa.initSign(priv);

            /* Update and sign the data */

            FileInputStream fis = new FileInputStream(args[0]);
            BufferedInputStream bufin = new BufferedInputStream(fis);
            byte[] buffer = new byte[1024];
            int len;
            while (bufin.available() != 0) {
                len = bufin.read(buffer);
                dsa.update(buffer, 0, len);
            }
            ;

            bufin.close();

            /*
             * Now that all the data to be signed has been read in, generate
             * a signature for it
             */

            byte[] realSig = dsa.sign();

            /* Save the signature in a file */
            FileOutputStream sigfos = new FileOutputStream("sig");
            sigfos.write(realSig);

            sigfos.close();

            /* Save the public key in a file */
            byte[] key = pub.getEncoded();
            FileOutputStream keyfos = new FileOutputStream("suepk");
            keyfos.write(key);

            keyfos.close();

        } catch (Exception e) {
            System.err.println("Caught exception " + e.toString());
        }

}

From source file:com.microsoft.azure.servicebus.samples.managingentity.ManagingEntity.java

public static void main(String[] args) {

    System.exit(runApp(args, (connectionString) -> {
        ManagingEntity app = new ManagingEntity();
        try {//from  w  w w . j av a 2  s . c om
            app.run(connectionString);
            return 0;
        } catch (Exception e) {
            System.out.printf("%s", e.toString());
            return 1;
        }
    }));
}

From source file:com.google.apigee.tools.HashcashTool.java

public static void main(String[] args) {
    try {//from   ww w. ja va 2 s . com
        HashcashTool me = new HashcashTool(args);
        me.run();
    } catch (java.lang.Exception exc1) {
        System.out.println("Exception:" + exc1.toString());
        exc1.printStackTrace();
    }
}

From source file:edu.harvard.med.screensaver.io.libraries.WellDeprecator.java

@SuppressWarnings("static-access")
public static void main(String[] args) {
    final CommandLineApplication app = new CommandLineApplication(args);
    app.addCommandLineOption(//from  www .j av a 2  s . co  m
            OptionBuilder.hasArg().isRequired().withArgName("admin user ID").withLongOpt("admin-approved-by")
                    .withDescription("user ID of administrator that approved this well deprecation activity")
                    .create("aa"));
    app.addCommandLineOption(
            OptionBuilder.hasArg().isRequired().withArgName("yyyy-mm-dd").withLongOpt("approval-date")
                    .withDescription("date this well deprecation activity was approved").create("d"));
    app.addCommandLineOption(
            OptionBuilder.hasArg().isRequired().withArgName("text").withLongOpt("comments").create("c"));
    app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("file").withLongOpt("input-file")
            .withDescription("workbook file containing list of wells to be deprecated").create("f"));
    app.processOptions(true, true);

    final GenericEntityDAO dao = (GenericEntityDAO) app.getSpringBean("genericEntityDao");

    dao.doInTransaction(new DAOTransaction() {
        public void runTransaction() {
            try {
                int size = updateWells(app, dao);
                System.out.println("WellDeprecator read in and added comments for " + size + " wells.");
            } catch (Exception e) {
                e.printStackTrace();
                log.error(e.toString());
                System.exit(1);
            }
        }
    });

}

From source file:edu.usc.polar.NLTKRest.java

public static void main(String args[]) {
    try {//from   w  ww. j a  va  2s  .  c  om
        String doc = "C:\\Users\\Snehal\\Documents\\TREC-Data\\Data\\1\\";
        System.out.println(ner.getEntityTypes() + " \t " + ner.isAvailable());
        dir(doc, args);
        if (jsonFile != null) {
            jsonFile.write("{\"NER_NLTKRest\":");
            jsonFile.write(jsonArray.toJSONString());
            jsonFile.write("}");
            // System.out.println(jsonArray.toJSONString());
            jsonFile.close();
        }

    } catch (Exception e) {
        System.out.println("Error" + e.toString());
        e.printStackTrace();
    }
}

From source file:de.ailis.microblinks.blinks.compiler.Main.java

/**
 * Main method.//  w  w w. j  ava 2 s .  com
 *
 * @param args
 *            The command-line arguments.
 */
public static void main(final String[] args) {
    final Main main = new Main();
    try {
        main.run(args);
    } catch (final Exception e) {
        if (main.debug) {
            log.error(e.toString(), e);
        } else {
            log.error(e.getMessage());
        }
        System.exit(1);
    }
}

From source file:edu.usc.polar.OpenNLP.java

public static void main(String args[]) {
    try {/*from   www .  j av a  2s. co  m*/
        ner = ner.instanceOpenNLPNERRecogniser(
                "C:\\Users\\Snehal\\Documents\\NetBeansProjects\\TIKANERSweet\\model");

        String doc = "C:\\Users\\Snehal\\Documents\\TREC-Data\\Data\\1\\";
        System.out.println(ner.getEntityTypes() + " \n " + ner.isAvailable());
        //Set<String> types = new OpenNLPNERRecogniser().getEntityTypes();
        dir(doc, args);
        if (jsonFile != null) {
            jsonFile.write("{\"NER_OpenNLP\":");
            jsonFile.write(jsonArray.toJSONString());
            jsonFile.write("}");
            // System.out.println(jsonArray.toJSONString());
            jsonFile.close();
        }

    } catch (Exception e) {
        System.out.println("Error" + e.toString());
        e.printStackTrace();
    }
}