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.queueswithproxy.QueuesWithProxy.java

public static void main(String[] args) {

    System.exit(runApp(args, (connectionString) -> {
        QueuesWithProxy app = new QueuesWithProxy();
        try {/*from   ww  w.jav a 2s. com*/
            app.run(connectionString);
            return 0;
        } catch (Exception e) {
            System.out.printf("%s", e.toString());
            return 1;
        }
    }));
}

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

@SuppressWarnings("static-access")
public static void main(String[] args) {
    CommandLineApplication app = new CommandLineApplication(args);
    try {/*from   w  w  w  .  ja  va 2 s  .c om*/
        DateTimeFormatter dateFormat = DateTimeFormat.forPattern(CommandLineApplication.DEFAULT_DATE_PATTERN);

        app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("library name")
                .withLongOpt("name").withDescription("full, official name for the library").create("n"));
        app.addCommandLineOption(
                OptionBuilder.hasArg().isRequired().withArgName("short name").withLongOpt("short-name")
                        .withDescription("a short name for identifying the library").create("s"));
        app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("library type")
                .withLongOpt("library-type").withDescription(StringUtils.makeListString(Lists.transform(
                        Lists.newArrayList(LibraryType.values()), new Function<LibraryType, String>() {
                            @Override
                            public String apply(LibraryType arg0) {
                                return arg0.name();
                            }
                        }), ", "))
                .create("lt"));
        app.addCommandLineOption(OptionBuilder.hasArg().isRequired().withArgName("screen type")
                .withLongOpt("screen-type").withDescription(StringUtils.makeListString(Lists
                        .transform(Lists.newArrayList(ScreenType.values()), new Function<ScreenType, String>() {
                            @Override
                            public String apply(ScreenType arg0) {
                                return arg0.name();
                            }
                        }), ", "))
                .create("st"));
        app.addCommandLineOption(OptionBuilder.hasArg(false).withLongOpt("is-pool")
                .withDescription("well contents are pools of reagents (only valid when library-type=RNAI)")
                .create("ip"));
        app.addCommandLineOption(
                OptionBuilder.hasArg().isRequired().withArgName("#").withLongOpt("start-plate").create("sp"));
        app.addCommandLineOption(
                OptionBuilder.hasArg().isRequired().withArgName("#").withLongOpt("end-plate").create("ep"));

        app.addCommandLineOption(
                OptionBuilder.hasArg().withArgName("name").withLongOpt("provider").create("lp"));
        app.addCommandLineOption(
                OptionBuilder.hasArg().withArgName("text").withLongOpt("description").create("d"));
        app.addCommandLineOption(OptionBuilder.hasArg().withArgName(CommandLineApplication.DEFAULT_DATE_PATTERN)
                .withLongOpt("date-received").create("dr"));
        app.addCommandLineOption(OptionBuilder.hasArg().withArgName(CommandLineApplication.DEFAULT_DATE_PATTERN)
                .withLongOpt("date-screenable").create("ds"));
        app.addCommandLineOption(OptionBuilder.hasArg().withArgName("plate size")
                .withDescription(StringUtils.makeListString(Lists
                        .transform(Lists.newArrayList(PlateSize.values()), new Function<PlateSize, String>() {
                            @Override
                            public String apply(PlateSize arg0) {
                                return arg0.name();
                            }
                        }), ", "))
                .withLongOpt("plate-size").create("ps"));

        app.processOptions(true, true);

        String libraryName = app.getCommandLineOptionValue("n");
        String shortName = app.getCommandLineOptionValue("s");
        LibraryType libraryType = app.getCommandLineOptionEnumValue("lt", LibraryType.class);
        boolean isPool = app.isCommandLineFlagSet("ip");
        ScreenType screenType = app.getCommandLineOptionEnumValue("st", ScreenType.class);
        int startPlate = app.getCommandLineOptionValue("sp", Integer.class);
        int endPlate = app.getCommandLineOptionValue("ep", Integer.class);
        String vendor = app.isCommandLineFlagSet("lp") ? app.getCommandLineOptionValue("lp") : null;
        String description = app.isCommandLineFlagSet("d") ? app.getCommandLineOptionValue("d") : null;
        LocalDate dateReceived = app.isCommandLineFlagSet("dr")
                ? app.getCommandLineOptionValue("dr", dateFormat).toLocalDate()
                : null;
        LocalDate dateScreenable = app.isCommandLineFlagSet("ds")
                ? app.getCommandLineOptionValue("ds", dateFormat).toLocalDate()
                : null;
        PlateSize plateSize = app.isCommandLineFlagSet("ps")
                ? app.getCommandLineOptionEnumValue("ps", PlateSize.class)
                : ScreensaverConstants.DEFAULT_PLATE_SIZE;

        Library library = new Library(app.findAdministratorUser(), libraryName, shortName, screenType,
                libraryType, startPlate, endPlate, plateSize);
        library.setPool(isPool);
        library.setDescription(description);
        library.setProvider(vendor);
        library.setDateReceived(dateReceived);
        library.setDateScreenable(dateScreenable);

        edu.harvard.med.screensaver.service.libraries.LibraryCreator libraryCreator = (edu.harvard.med.screensaver.service.libraries.LibraryCreator) app
                .getSpringBean("libraryCreator");
        libraryCreator.createLibrary(library);
        log.info("library succesfully added to database");
    } catch (Exception e) {
        e.printStackTrace();
        log.error(e.toString());
        System.err.println("error: " + e.getMessage());
        System.exit(1);
    }
}

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

public static void main(String args[]) {
    try {//from ww  w . j  a  va  2  s  .  c om
        String doc = "C:\\Users\\Snehal\\Documents\\TREC-Data\\Data\\1\\";
        serializedClassifier = "classifiers/english.muc.7class.distsim.crf.ser.gz";
        classifier = CRFClassifier.getClassifier(serializedClassifier);
        //USAGE   tikaCoreNLP(doc);
        dir(doc, args);

        if (jsonFile != null) {
            jsonFile.write("{\"NER_CoreNLP\":");
            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:com.microsoft.azure.servicebus.samples.timetolive.TimeToLive.java

public static void main(String[] args) {

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

From source file:azureml_besapp.AzureML_BESApp.java

/**
 * @param args the command line arguments specifying JSON and API info file names
 *///from  w w  w  .  j  a v a2s  .c  o  m
public static void main(String[] args) {
    // check for mandatory argments. This program expects 2 arguments 
    // first argument is full path with file name of JSON file and 
    // second argument is full path with file name of API file that contains API URL and API Key of request response REST API
    if (args.length < 2) {
        System.out.println("Incorrect usage. Please use the following calling pattern");
        System.out.println("java AzureML_BESApp <jsonFilename> <apiInfo Filename>");
    }

    try {

        // read JSON file name
        String jsonFile = args[0];
        // read API file name
        String apiFile = args[1];

        // call method to read API URL and key from API file
        readApiInfo(apiFile);

        // call method to read JSON input from the JSON file
        readJson(jsonFile);

        // print the response from Submit Job REST API
        System.out.println(besHttpPost());
        // print the respons from Start Job REST API
        System.out.println(besStartJob());

        //System.out.println(besStartJob("1ebfc0453a214f5a90114d962827fd45"));
        //System.out.println(besCancelJob("1202a382bf41443ba997dea7f8944b6e"));

    } catch (Exception e) {
        System.out.println(e.toString());
    }
}

From source file:com.aerospike.developer.training.Program.java

public static void main(String[] args) throws AerospikeException {
    try {/*w  w  w .j a va 2 s.  c  o m*/

        Program as = new Program();

        as.work();

    } catch (Exception e) {
        System.out.printf(e.toString());
    }
}

From source file:com.microsoft.azure.servicebus.samples.deadletterqueue.DeadletterQueue.java

public static void main(String[] args) {

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

From source file:com.google.examples.JwtTool.java

public static void main(String[] args) {
    try {/*ww  w.j a  v a2 s . c om*/
        JwtTool me = new JwtTool(args);
        me.run();
    } catch (java.lang.Exception exc1) {
        System.out.println("Exception:" + exc1.toString());
        exc1.printStackTrace();
        usage();
    }
}

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

public static void main(String args[]) {
    try {//from  w w  w . j a  v  a2s  .  c  om
        String doc = "C:\\Users\\Snehal\\Documents\\TREC-Data\\Data\\";
        nltkNer = new NLTKNERecogniser();
        coreNer = new CoreNLPNERecogniser(
                "C:\\Users\\Snehal\\Documents\\NetBeansProjects\\TIKANERSweet\\classifiers\\english.muc.7class.distsim.crf.ser.gz");
        openNer = openNer.instanceOpenNLPNERRecogniser(
                "C:\\Users\\Snehal\\Documents\\NetBeansProjects\\TIKANERSweet\\model");

        System.out.println(" NLTK-Rest : " + nltkNer.getEntityTypes() + " \t " + nltkNer.isAvailable());
        System.out.println(" OpenNLP : " + openNer.getEntityTypes() + " \t " + openNer.isAvailable());
        System.out.println(" StanfordNLP : " + coreNer.getEntityTypes() + " \t " + coreNer.isAvailable());
        dir(doc, args);
        if (jsonFile != null) {
            jsonFile.write("{\"CompositeNER\":");
            jsonFile.write(jsonArray.toJSONString());
            jsonFile.write("}");
            // System.out.println(jsonArray.toJSONString());
            jsonFile.close();
        }
        file = new File("C:\\Users\\Snehal\\Documents\\tikaSimilarityTestSet\\CompositeNER\\JointAgreement_"
                + jsonCount + ".json");
        jsonFile = new FileWriter(file);
        if (jsonFile != null) {
            jsonFile.write("{\"JointAgreement\":");
            jsonFile.write(jsonAgree.toJSONString());
            jsonFile.write("}");
            // System.out.println(jsonArray.toJSONString());
            jsonFile.close();
        }

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

}

From source file:OCRRestAPI.java

public static void main(String[] args) throws Exception {
    /*/*from   w w  w  .jav  a 2 s  .c o  m*/
              
         Sample project for OCRWebService.com (REST API).
         Extract text from scanned images and convert into editable formats.
         Please create new account with ocrwebservice.com via http://www.ocrwebservice.com/account/signup and get license code
            
     */

    // Provide your user name and license code
    String license_code = "88EF173D-CDEA-41B6-8D64-C04578ED8C4D";
    String user_name = "FERGOID";

    /*
            
      You should specify OCR settings. See full description http://www.ocrwebservice.com/service/restguide
             
      Input parameters:
             
     [language]      - Specifies the recognition language. 
                  This parameter can contain several language names separated with commas. 
                    For example "language=english,german,spanish".
               Optional parameter. By default:english
            
     [pagerange]     - Enter page numbers and/or page ranges separated by commas. 
               For example "pagerange=1,3,5-12" or "pagerange=allpages".
                    Optional parameter. By default:allpages
             
      [tobw]           - Convert image to black and white (recommend for color image and photo). 
               For example "tobw=false"
                    Optional parameter. By default:false
             
      [zone]          - Specifies the region on the image for zonal OCR. 
               The coordinates in pixels relative to the left top corner in the following format: top:left:height:width. 
               This parameter can contain several zones separated with commas. 
                 For example "zone=0:0:100:100,50:50:50:50"
                    Optional parameter.
              
      [outputformat]  - Specifies the output file format.
                    Can be specified up to two output formats, separated with commas.
               For example "outputformat=pdf,txt"
                    Optional parameter. By default:doc
            
      [gettext]      - Specifies that extracted text will be returned.
               For example "tobw=true"
                    Optional parameter. By default:false
            
       [description]  - Specifies your task description. Will be returned in response.
                    Optional parameter. 
            
            
     !!!!  For getting result you must specify "gettext" or "outputformat" !!!!  
            
    */

    // Build your OCR:

    // Extraction text with English language
    String ocrURL = "http://www.ocrwebservice.com/restservices/processDocument?gettext=true";

    // Extraction text with English and German language using zonal OCR
    ocrURL = "http://www.ocrwebservice.com/restservices/processDocument?language=english,german&zone=0:0:600:400,500:1000:150:400";

    // Convert first 5 pages of multipage document into doc and txt
    // ocrURL = "http://www.ocrwebservice.com/restservices/processDocument?language=english&pagerange=1-5&outputformat=doc,txt";

    // Full path to uploaded document
    String filePath = "sarah-morgan.jpg";

    byte[] fileContent = Files.readAllBytes(Paths.get(filePath));

    URL url = new URL(ocrURL);

    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setDoOutput(true);
    connection.setDoInput(true);
    connection.setRequestMethod("POST");

    connection.setRequestProperty("Authorization",
            "Basic " + Base64.getEncoder().encodeToString((user_name + ":" + license_code).getBytes()));

    // Specify Response format to JSON or XML (application/json or application/xml)
    connection.setRequestProperty("Content-Type", "application/json");

    connection.setRequestProperty("Content-Length", Integer.toString(fileContent.length));

    int httpCode;
    try (OutputStream stream = connection.getOutputStream()) {

        // Send POST request
        stream.write(fileContent);
        stream.close();
    } catch (Exception e) {
        System.out.println(e.toString());
    }

    httpCode = connection.getResponseCode();

    System.out.println("HTTP Response code: " + httpCode);

    // Success request
    if (httpCode == HttpURLConnection.HTTP_OK) {
        // Get response stream
        String jsonResponse = GetResponseToString(connection.getInputStream());

        // Parse and print response from OCR server
        PrintOCRResponse(jsonResponse);
    } else if (httpCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
        System.out.println("OCR Error Message: Unauthorizied request");
    } else {
        // Error occurred
        String jsonResponse = GetResponseToString(connection.getErrorStream());

        JSONParser parser = new JSONParser();
        JSONObject jsonObj = (JSONObject) parser.parse(jsonResponse);

        // Error message
        System.out.println("Error Message: " + jsonObj.get("ErrorMessage"));
    }

    connection.disconnect();

}