Example usage for java.lang RuntimeException getMessage

List of usage examples for java.lang RuntimeException getMessage

Introduction

In this page you can find the example usage for java.lang RuntimeException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.espertech.esper.example.trivia.TriviaMain.java

public static void main(String[] args) {

    try {/*from   w w  w  .  j a va 2s  .c o  m*/
        TriviaMain main = new TriviaMain();
        main.run();
    } catch (RuntimeException ex) {
        log.error("Unexpected exception encountered: " + ex.getMessage(), ex);
    }
}

From source file:com.fluidops.iwb.deepzoom.ImageLoader.java

public static void main(String[] args) {
    URL url;//from  w  w w. ja  va  2 s  . c o  m
    try {
        url = new URL("http://ajax.googleapis.com/ajax/services/search/images?v=1.0&" + "q=dbpedia");

        URLConnection connection = url.openConnection();
        connection.addRequestProperty("Referer", "http://iwb.fluidops.com/");

        String content = GenUtil.readUrl(connection.getInputStream());

        JSONObject json = new JSONObject(content);
        System.out.println(json);
    } catch (RuntimeException e) {
        logger.error(e.getMessage(), e);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }

}

From source file:com.mycompany.javaapplicaton3.LerArquivo2.java

/**
 * @param args/* ww w.j  av  a  2  s  . c o  m*/
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    String SAMPLE_PERSON_DATA_FILE_PATH = "C:/Users/lprates/Documents/arquivo2013.xlsx";

    // Input File initialize
    File file = new File(SAMPLE_PERSON_DATA_FILE_PATH);
    InputStream inputStream = new FileInputStream(file);

    // Excel Cell Mapping
    Map<String, String> cellMapping0150 = new HashMap<String, String>();
    cellMapping0150.put("HEADER",
            "REG,COD_PART,NOME,COD_PAIS,CNPJ,CPF,IE,COD_MUN,SUFRAMA,END,NUM,COMPL,BAIRRO,BPE_VIGENCIA_FIN");
    cellMapping0150.put("A", "reg");
    cellMapping0150.put("B", "codPart");
    cellMapping0150.put("C", "nome");
    cellMapping0150.put("D", "codPais");
    cellMapping0150.put("E", "cnpj");
    cellMapping0150.put("F", "cpf");
    cellMapping0150.put("G", "ie");
    cellMapping0150.put("H", "codMun");
    cellMapping0150.put("I", "suframa");
    cellMapping0150.put("J", "end");
    cellMapping0150.put("K", "num");
    cellMapping0150.put("L", "compl");
    cellMapping0150.put("M", "bairro");
    cellMapping0150.put("N", "bpeVigenciaFin");

    // Excel Cell Mapping
    Map<String, String> cellMapping0200 = new HashMap<String, String>();
    cellMapping0200.put("HEADER",
            "REG,COD_ITEM,DESCR_ITEM,COD_BARRA,COD_ANT_ITEM,UNID_INV,TIPO_ITEM,COD_NCM,EX_IPI,COD_GEN,COD_LST,ALIQ_ICMS");
    cellMapping0200.put("A", "reg");
    cellMapping0200.put("B", "codItem");
    cellMapping0200.put("C", "descrItem");
    cellMapping0200.put("D", "codBarra");
    cellMapping0200.put("E", "codAntItem");
    cellMapping0200.put("F", "unidInv");
    cellMapping0200.put("G", "tipoItem");
    cellMapping0200.put("H", "codNcm");
    cellMapping0200.put("I", "exIpi");
    cellMapping0200.put("J", "codGen");
    cellMapping0200.put("K", "codLst");
    cellMapping0200.put("L", "aliqIcms");

    // Excel Cell Mapping
    Map<String, String> cellMappingC100_C170 = new HashMap<String, String>();
    cellMappingC100_C170.put("A", "campo1");
    cellMappingC100_C170.put("B", "campo2");
    cellMappingC100_C170.put("C", "campo3");
    cellMappingC100_C170.put("D", "campo4");
    cellMappingC100_C170.put("E", "campo5");
    cellMappingC100_C170.put("F", "campo6");
    cellMappingC100_C170.put("G", "campo7");
    cellMappingC100_C170.put("H", "campo8");
    cellMappingC100_C170.put("I", "campo9");
    cellMappingC100_C170.put("J", "campo10");
    cellMappingC100_C170.put("K", "campo11");
    cellMappingC100_C170.put("L", "campo12");
    cellMappingC100_C170.put("M", "campo13");
    cellMappingC100_C170.put("N", "campo14");
    cellMappingC100_C170.put("O", "campo15");
    cellMappingC100_C170.put("P", "campo16");
    cellMappingC100_C170.put("Q", "campo17");
    cellMappingC100_C170.put("R", "campo18");
    cellMappingC100_C170.put("S", "campo19");
    cellMappingC100_C170.put("T", "campo20");
    cellMappingC100_C170.put("U", "campo21");
    cellMappingC100_C170.put("V", "campo22");
    cellMappingC100_C170.put("W", "campo23");
    cellMappingC100_C170.put("X", "campo24");
    cellMappingC100_C170.put("Y", "campo25");
    cellMappingC100_C170.put("Z", "campo26");

    cellMappingC100_C170.put("AA", "campo27");
    cellMappingC100_C170.put("AB", "campo28");
    cellMappingC100_C170.put("AC", "campo29");
    cellMappingC100_C170.put("AD", "campo30");
    cellMappingC100_C170.put("AE", "campo31");
    cellMappingC100_C170.put("AF", "campo32");
    cellMappingC100_C170.put("AG", "campo33");
    cellMappingC100_C170.put("AH", "campo34");
    cellMappingC100_C170.put("AI", "campo35");
    cellMappingC100_C170.put("AJ", "campo36");
    cellMappingC100_C170.put("AK", "campo37");
    cellMappingC100_C170.put("AL", "campo38");
    cellMappingC100_C170.put("AM", "campo39");
    cellMappingC100_C170.put("AN", "campo40");
    cellMappingC100_C170.put("AO", "campo41");
    cellMappingC100_C170.put("AP", "campo42");
    cellMappingC100_C170.put("AQ", "campo43");
    cellMappingC100_C170.put("AR", "campo44");
    cellMappingC100_C170.put("AS", "campo45");
    cellMappingC100_C170.put("AT", "campo46");
    cellMappingC100_C170.put("AU", "campo47");
    cellMappingC100_C170.put("AV", "campo48");
    cellMappingC100_C170.put("AW", "campo49");
    cellMappingC100_C170.put("AX", "campo50");
    cellMappingC100_C170.put("AY", "campo51");
    cellMappingC100_C170.put("AZ", "campo52");

    cellMappingC100_C170.put("BA", "campo53");
    cellMappingC100_C170.put("BB", "campo54");
    cellMappingC100_C170.put("BC", "campo55");
    cellMappingC100_C170.put("BD", "campo56");
    cellMappingC100_C170.put("BE", "campo57");
    cellMappingC100_C170.put("BF", "campo58");
    cellMappingC100_C170.put("BG", "campo59");
    cellMappingC100_C170.put("BH", "campo60");
    cellMappingC100_C170.put("BI", "campo61");
    cellMappingC100_C170.put("BJ", "campo62");
    cellMappingC100_C170.put("BK", "campo63");
    cellMappingC100_C170.put("BL", "campo64");
    cellMappingC100_C170.put("BM", "campo65");
    cellMappingC100_C170.put("BN", "campo66");
    cellMappingC100_C170.put("BO", "campo67");
    cellMappingC100_C170.put("BP", "campo68");
    cellMappingC100_C170.put("BQ", "campo69");
    cellMappingC100_C170.put("BR", "campo70");
    cellMappingC100_C170.put("BS", "campo71");

    // The package open is instantaneous, as it should be.
    OPCPackage pkg = null;
    try {

        ExcelWorkSheetHandler<Reg0150> workSheetHandler = new ExcelWorkSheetHandler<Reg0150>(Reg0150.class,
                cellMapping0150);

        pkg = OPCPackage.open(inputStream);

        ExcelSheetCallback sheetCallback = new ExcelSheetCallback() {
            private int sheetNumber = 0;

            public void startSheet(int sheetNum, String sheetName) {
                this.sheetNumber = sheetNum;
                System.out.println("Started processing sheet number=" + sheetNumber + " and Sheet Name is '"
                        + sheetName + "'");
            }

            @Override
            public void endSheet() {
                System.out.println("Processing completed for sheet number=" + sheetNumber);
            }

            public void startSheet(int sheetNum) {
                System.out.println("Started processing sheet number=" + sheetNum);
            }

        };

        /*** Leitura Registro 0150 ***/

        System.out.println("Constructor: pkg, workSheetHandler, sheetCallback");
        ExcelReader example1 = new ExcelReader(pkg, workSheetHandler, sheetCallback);
        example1.process("0150");

        if (workSheetHandler.getValueList().isEmpty()) {
            // No data present
            LOG.error("sHandler.getValueList() is empty");
        } else {

            LOG.info(workSheetHandler.getValueList().size()
                    + " no. of records read from given excel worksheet successfully.");

            // Displaying data ead from Excel file
            displayPersonList(workSheetHandler.getValueList());
        }

        /*** Leitura Registro 0200 ***/

        ExcelWorkSheetHandler<Reg0200> workSheetHandler0200 = new ExcelWorkSheetHandler<Reg0200>(Reg0200.class,
                cellMapping0200);

        ExcelReader example2 = new ExcelReader(pkg, workSheetHandler0200, null);
        example2.process("0200");

        if (workSheetHandler0200.getValueList().isEmpty()) {

            LOG.error("sHandler.getValueList() is empty");
        } else {

            LOG.info(workSheetHandler0200.getValueList().size()
                    + " no. of records read from given excel worksheet successfully.");

            displayPersonList0200(workSheetHandler0200.getValueList());
        }

        /*** Leitura Registro C100 e C170 ***/

        ExcelWorkSheetHandler<RegC100_C170> workSheetHandlerC100_C170 = new ExcelWorkSheetHandler<RegC100_C170>(
                RegC100_C170.class, cellMappingC100_C170, 4);
        workSheetHandlerC100_C170.setVerifiyHeader(false);

        ExcelReader example3 = new ExcelReader(pkg, workSheetHandlerC100_C170, null);
        example3.process("201302");

        if (workSheetHandlerC100_C170.getValueList().isEmpty()) {

            LOG.error("sHandler.getValueList() is empty");
        } else {

            LOG.info(workSheetHandlerC100_C170.getValueList().size()
                    + " no. of records read from given excel worksheet successfully.");

            displayPersonListC100_C170(workSheetHandlerC100_C170.getValueList());
        }

    } catch (RuntimeException are) {
        LOG.error(are.getMessage(), are.getCause());
    } catch (InvalidFormatException ife) {
        LOG.error(ife.getMessage(), ife.getCause());
    } catch (IOException ioe) {
        LOG.error(ioe.getMessage(), ioe.getCause());
    } finally {
        IOUtils.closeQuietly(inputStream);
        try {
            if (null != pkg) {
                pkg.close();
            }
        } catch (IOException e) {
            // just ignore IO exception
        }
    }
}

From source file:com.msd.gin.halyard.tools.HalyardExport.java

/**
 * Main of the HalyardExport// w  w  w  . j  a v a  2  s  .  co  m
 * @param args String command line arguments
 * @throws Exception throws Exception in case of any problem
 */
public static void main(final String args[]) throws Exception {
    if (conf == null)
        conf = new Configuration();
    Options options = new Options();
    options.addOption(newOption("h", null, "Prints this help"));
    options.addOption(newOption("v", null, "Prints version"));
    options.addOption(newOption("s", "source_htable", "Source HBase table with Halyard RDF store"));
    options.addOption(
            newOption("q", "sparql_query", "SPARQL tuple or graph query executed to export the data"));
    options.addOption(newOption("t", "target_url",
            "file://<path>/<file_name>.<ext> or hdfs://<path>/<file_name>.<ext> or jdbc:<jdbc_connection>/<table_name>"));
    options.addOption(newOption("p", "property=value", "JDBC connection properties"));
    options.addOption(newOption("l", "driver_classpath", "JDBC driver classpath delimited by ':'"));
    options.addOption(newOption("c", "driver_class", "JDBC driver class name"));
    options.addOption(newOption("r", null, "Trim target table before export (apply for JDBC only)"));
    try {
        CommandLine cmd = new PosixParser().parse(options, args);
        if (args.length == 0 || cmd.hasOption('h')) {
            printHelp(options);
            return;
        }
        if (cmd.hasOption('v')) {
            Properties p = new Properties();
            try (InputStream in = HalyardExport.class
                    .getResourceAsStream("/META-INF/maven/com.msd.gin.halyard/hbasesail/pom.properties")) {
                if (in != null)
                    p.load(in);
            }
            System.out.println("Halyard Export version " + p.getProperty("version", "unknown"));
            return;
        }
        if (!cmd.getArgList().isEmpty())
            throw new ExportException("Unknown arguments: " + cmd.getArgList().toString());
        for (char c : "sqt".toCharArray()) {
            if (!cmd.hasOption(c))
                throw new ExportException("Missing mandatory option: " + c);
        }
        for (char c : "sqtlc".toCharArray()) {
            String s[] = cmd.getOptionValues(c);
            if (s != null && s.length > 1)
                throw new ExportException("Multiple values for option: " + c);
        }
        StatusLog log = new StatusLog() {
            private final Logger l = Logger.getLogger(HalyardExport.class.getName());

            @Override
            public void tick() {
            }

            @Override
            public void logStatus(String status) {
                l.info(status);
            }
        };
        String driverClasspath = cmd.getOptionValue('l');
        URL driverCP[] = null;
        if (driverClasspath != null) {
            String jars[] = driverClasspath.split(":");
            driverCP = new URL[jars.length];
            for (int j = 0; j < jars.length; j++) {
                File f = new File(jars[j]);
                if (!f.isFile())
                    throw new ExportException("Invalid JDBC driver classpath element: " + jars[j]);
                driverCP[j] = f.toURI().toURL();
            }
        }
        export(conf, log, cmd.getOptionValue('s'), cmd.getOptionValue('q'), cmd.getOptionValue('t'),
                cmd.getOptionValue('c'), driverCP, cmd.getOptionValues('p'), cmd.hasOption('r'));
    } catch (RuntimeException exp) {
        System.out.println(exp.getMessage());
        printHelp(options);
        throw exp;
    }
}

From source file:com.opengamma.util.db.tool.DbTool.java

/**
 * Runs the tool from the command line.//from   www.  ja v  a2 s.  c  o  m
 * 
 * @param args  the command line arguments, not null
 */
public static void main(String[] args) { // CSIGNORE
    Options options = new Options();
    options.addOption("jdbcUrl", "jdbcUrl", true,
            "DB server URL + database - for example, jdbc:postgresql://localhost:1234/OpenGammaTests. You can use"
                    + " either this option or specify server and database separately.");
    options.addOption("server", "server", true,
            "DB server URL (no database at the end) - for example, jdbc:postgresql://localhost:1234");
    options.addOption("database", "database", true,
            "Name of database on the DB server - for example, OpenGammaTests");
    options.addOption("user", "user", true, "User name to the DB");
    options.addOption("password", "password", true, "Password to the DB");
    options.addOption("schema", "schema", true,
            "Name of schema within database. Optional. If not specified, the default schema for the database is used.");
    options.addOption("create", "create", false,
            "Creates the given database/schema. The database will be empty.");
    options.addOption("drop", "drop", false, "Drops all tables and sequences within the given database/schema");
    options.addOption("clear", "clear", false, "Clears all tables within the given database/schema");
    options.addOption("createtestdb", "createtestdb", true,
            "Drops schema in database test_<user.name> and recreates it (including tables). "
                    + "{dbtype} should be one of derby, postgres, all. Connection parameters are read from test.properties so you do not need "
                    + "to specify server, user, or password.");
    options.addOption("createtables", "createtables", true, "Creates database tables for all masters.");
    options.addOption("targetversion", "targetversion", true,
            "Version number for the end result database. 0 means latest. 1 means last but one etc. Optional. If not specified, assumes latest version.");
    options.addOption("createversion", "createversion", true,
            "Version number to run the creation script from. 0 means latest. 1 means last but one etc. Optional. If not specified, defaults to {targetversion}.");
    options.addOption("testpropertiesdir", "testpropertiesdir", true,
            "Directory for reading test.properties. Only used with the --createstdb option. "
                    + "Optional. If not specified, the working directory is used.");

    CommandLineParser parser = new PosixParser();
    CommandLine line = null;
    try {
        line = parser.parse(options, args);
    } catch (ParseException e) {
        e.printStackTrace();
        usage(options);
        System.exit(-1);
    }

    DbTool tool = new DbTool();
    tool.setJdbcUrl(line.getOptionValue("jdbcUrl"));
    tool.setDbServerHost(line.getOptionValue("server"));
    tool.setUser(line.getOptionValue("user"));
    tool.setPassword(line.getOptionValue("password"));
    tool.setCatalog(line.getOptionValue("database"));
    tool.setSchema(line.getOptionValue("schema"));
    tool.setCreate(line.hasOption("create"));
    tool.setDrop(line.hasOption("drop"));
    tool.setClear(line.hasOption("clear"));
    tool.setCreateTestDb(line.getOptionValue("createtestdb"));
    tool.setCreateTables(line.getOptionValue("createtables"));
    tool.setTestPropertiesDir(line.getOptionValue("testpropertiesdir"));
    tool.setTargetVersion(line.getOptionValue("targetversion"));
    tool.setCreateVersion(line.getOptionValue("createversion"));

    try {
        tool.execute();
    } catch (RuntimeException ex) {
        s_logger.error(ex.getMessage());
        usage(options);
        System.exit(-1);
    }
}

From source file:com.cyberway.issue.io.warc.WARCReader.java

/**
 * Command-line interface to WARCReader.
 *
 * Here is the command-line interface://w  ww. ja va2 s.  c  o m
 * <pre>
 * usage: java com.cyberway.issue.io.arc.WARCReader [--offset=#] ARCFILE
 *  -h,--help      Prints this message and exits.
 *  -o,--offset    Outputs record at this offset into arc file.</pre>
 *
 * <p>Outputs using a pseudo-CDX format as described here:
 * <a href="http://www.archive.org/web/researcher/cdx_legend.php">CDX
 * Legent</a> and here
 * <a href="http://www.archive.org/web/researcher/example_cdx.php">Example</a>.
 * Legend used in below is: 'CDX b e a m s c V (or v if uncompressed) n g'.
 * Hash is hard-coded straight SHA-1 hash of content.
 *
 * @param args Command-line arguments.
 * @throws ParseException Failed parse of the command line.
 * @throws IOException
 * @throws java.text.ParseException
 */
public static void main(String[] args) throws ParseException, IOException, java.text.ParseException {
    Options options = getOptions();
    PosixParser parser = new PosixParser();
    CommandLine cmdline = parser.parse(options, args, false);
    List cmdlineArgs = cmdline.getArgList();
    Option[] cmdlineOptions = cmdline.getOptions();
    HelpFormatter formatter = new HelpFormatter();

    // If no args, print help.
    if (cmdlineArgs.size() <= 0) {
        usage(formatter, options, 0);
    }

    // Now look at options passed.
    long offset = -1;
    boolean digest = false;
    boolean strict = false;
    String format = CDX;
    for (int i = 0; i < cmdlineOptions.length; i++) {
        switch (cmdlineOptions[i].getId()) {
        case 'h':
            usage(formatter, options, 0);
            break;

        case 'o':
            offset = Long.parseLong(cmdlineOptions[i].getValue());
            break;

        case 's':
            strict = true;
            break;

        case 'd':
            digest = getTrueOrFalse(cmdlineOptions[i].getValue());
            break;

        case 'f':
            format = cmdlineOptions[i].getValue().toLowerCase();
            boolean match = false;
            // List of supported formats.
            final String[] supportedFormats = { CDX, DUMP, GZIP_DUMP, CDX_FILE };
            for (int ii = 0; ii < supportedFormats.length; ii++) {
                if (supportedFormats[ii].equals(format)) {
                    match = true;
                    break;
                }
            }
            if (!match) {
                usage(formatter, options, 1);
            }
            break;

        default:
            throw new RuntimeException("Unexpected option: " + +cmdlineOptions[i].getId());
        }
    }

    if (offset >= 0) {
        if (cmdlineArgs.size() != 1) {
            System.out.println("Error: Pass one arcfile only.");
            usage(formatter, options, 1);
        }
        WARCReader r = WARCReaderFactory.get(new File((String) cmdlineArgs.get(0)), offset);
        r.setStrict(strict);
        outputRecord(r, format);
    } else {
        for (Iterator i = cmdlineArgs.iterator(); i.hasNext();) {
            String urlOrPath = (String) i.next();
            try {
                WARCReader r = WARCReaderFactory.get(urlOrPath);
                r.setStrict(strict);
                r.setDigest(digest);
                output(r, format);
            } catch (RuntimeException e) {
                // Write out name of file we failed on to help with
                // debugging.  Then print stack trace and try to keep
                // going.  We do this for case where we're being fed
                // a bunch of ARCs; just note the bad one and move
                // on to the next.
                System.err.println("Exception processing " + urlOrPath + ": " + e.getMessage());
                e.printStackTrace(System.err);
                System.exit(1);
            }
        }
    }
}

From source file:com.cyberway.issue.io.arc.ARCReader.java

/**
 * Command-line interface to ARCReader.// w w  w.j a  v a  2 s.c  om
 *
 * Here is the command-line interface:
 * <pre>
 * usage: java com.cyberway.issue.io.arc.ARCReader [--offset=#] ARCFILE
 *  -h,--help      Prints this message and exits.
 *  -o,--offset    Outputs record at this offset into arc file.</pre>
 *
 * <p>See in <code>$HERITRIX_HOME/bin/arcreader</code> for a script that'll
 * take care of classpaths and the calling of ARCReader.
 *
 * <p>Outputs using a pseudo-CDX format as described here:
 * <a href="http://www.archive.org/web/researcher/cdx_legend.php">CDX
 * Legent</a> and here
 * <a href="http://www.archive.org/web/researcher/example_cdx.php">Example</a>.
 * Legend used in below is: 'CDX b e a m s c V (or v if uncompressed) n g'.
 * Hash is hard-coded straight SHA-1 hash of content.
 *
 * @param args Command-line arguments.
 * @throws ParseException Failed parse of the command line.
 * @throws IOException
 * @throws java.text.ParseException
 */
public static void main(String[] args) throws ParseException, IOException, java.text.ParseException {
    Options options = getOptions();
    options.addOption(new Option("p", "parse", false, "Parse headers."));
    PosixParser parser = new PosixParser();
    CommandLine cmdline = parser.parse(options, args, false);
    List cmdlineArgs = cmdline.getArgList();
    Option[] cmdlineOptions = cmdline.getOptions();
    HelpFormatter formatter = new HelpFormatter();

    // If no args, print help.
    if (cmdlineArgs.size() <= 0) {
        usage(formatter, options, 0);
    }

    // Now look at options passed.
    long offset = -1;
    boolean digest = false;
    boolean strict = false;
    boolean parse = false;
    String format = CDX;
    for (int i = 0; i < cmdlineOptions.length; i++) {
        switch (cmdlineOptions[i].getId()) {
        case 'h':
            usage(formatter, options, 0);
            break;

        case 'o':
            offset = Long.parseLong(cmdlineOptions[i].getValue());
            break;

        case 's':
            strict = true;
            break;

        case 'p':
            parse = true;
            break;

        case 'd':
            digest = getTrueOrFalse(cmdlineOptions[i].getValue());
            break;

        case 'f':
            format = cmdlineOptions[i].getValue().toLowerCase();
            boolean match = false;
            // List of supported formats.
            final String[] supportedFormats = { CDX, DUMP, GZIP_DUMP, HEADER, NOHEAD, CDX_FILE };
            for (int ii = 0; ii < supportedFormats.length; ii++) {
                if (supportedFormats[ii].equals(format)) {
                    match = true;
                    break;
                }
            }
            if (!match) {
                usage(formatter, options, 1);
            }
            break;

        default:
            throw new RuntimeException("Unexpected option: " + +cmdlineOptions[i].getId());
        }
    }

    if (offset >= 0) {
        if (cmdlineArgs.size() != 1) {
            System.out.println("Error: Pass one arcfile only.");
            usage(formatter, options, 1);
        }
        ARCReader arc = ARCReaderFactory.get((String) cmdlineArgs.get(0), offset);
        arc.setStrict(strict);
        // We must parse headers if we need to skip them.
        if (format.equals(NOHEAD) || format.equals(HEADER)) {
            parse = true;
        }
        arc.setParseHttpHeaders(parse);
        outputRecord(arc, format);
    } else {
        for (Iterator i = cmdlineArgs.iterator(); i.hasNext();) {
            String urlOrPath = (String) i.next();
            try {
                ARCReader r = ARCReaderFactory.get(urlOrPath);
                r.setStrict(strict);
                r.setParseHttpHeaders(parse);
                r.setDigest(digest);
                output(r, format);
            } catch (RuntimeException e) {
                // Write out name of file we failed on to help with
                // debugging.  Then print stack trace and try to keep
                // going.  We do this for case where we're being fed
                // a bunch of ARCs; just note the bad one and move
                // on to the next.
                System.err.println("Exception processing " + urlOrPath + ": " + e.getMessage());
                e.printStackTrace(System.err);
                System.exit(1);
            }
        }
    }
}

From source file:Main.java

public static void setDefaultFont(Context context, String path, String fontName) {
    try {/*from   ww w.  ja  v  a  2 s  . c om*/
        defaultTypeFace = Typeface.createFromAsset(context.getAssets(), path + "/" + fontName + ".ttf");
    } catch (RuntimeException e) {
        if (e.getMessage().equals("native typeface cannot be made")) {
            try {
                throw new Exception("the fontName that you use does not exist in the file path!!");
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
}

From source file:edu.eci.pdsw.samples.managedbeans.PagoAfiliacionBean.java

public static Object getManagedBean(final String beanName) {
    FacesContext fc = FacesContext.getCurrentInstance();

    Object bean;/*from www  .ja  va  2 s  .c om*/
    try {
        ELContext elContext = fc.getELContext();
        bean = elContext.getELResolver().getValue(elContext, null, beanName);
    } catch (RuntimeException e) {
        throw new FacesException(e.getMessage(), e);

    }
    return bean;
}

From source file:org.envirocar.app.network.HTTPClient.java

public static synchronized void shutdown() {
    if (client != null) {
        try {/*from  w w  w .ja  v  a  2  s . co  m*/
            client.close();
        } catch (RuntimeException e) {
            logger.warn(e.getMessage(), e);
        }
    }
}