Example usage for java.lang Exception getLocalizedMessage

List of usage examples for java.lang Exception getLocalizedMessage

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:android.databinding.tool.MakeCopy.java

private static Document readAndroidManifest(File manifest) {
    try {/* w w w .j  av  a  2 s .  co  m*/
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder documentBuilder = dbf.newDocumentBuilder();
        return documentBuilder.parse(manifest);
    } catch (Exception e) {
        System.err.println("Could not load Android Manifest from " + manifest.getAbsolutePath() + ": "
                + e.getLocalizedMessage());
        System.exit(8);
        return null;
    }
}

From source file:com.aotome202.lostjason.e202project.apputils.MLog.java

public static void errorLog(Exception e) {
    if (e == null) {
        return;/*from www. ja  va 2  s .  c o m*/
    }

    printLog(E, null, e.getLocalizedMessage());
}

From source file:com.spoiledmilk.ibikecph.search.HTTPAutocompleteHandler.java

public static List<JsonNode> getKortforsyningenAutocomplete(Location currentLocation, Address address) {
    String urlString;/*from   w ww  . j a  va  2  s.  c o m*/
    List<JsonNode> list = new ArrayList<JsonNode>();
    try {

        urlString = "http://kortforsyningen.kms.dk/?servicename=RestGeokeys_v2&method=";

        if ((address.number == null || address.number.equals(""))
                && (address.zip == null || address.zip.equals(""))
                && (address.city == null || address.city.equals("") || address.city.equals(address.street))) {
            urlString += "vej"; // street search
        } else {
            urlString += "adresse"; // address search
        }

        urlString += "&vejnavn=*" + URLEncoder.encode(address.street, "UTF-8") + "*";

        if (!(address.number == null || address.number.equals(""))) {
            urlString += "&husnr=" + address.number;
        }

        urlString += "&geop=" + Util.limitDecimalPlaces(currentLocation.getLongitude(), 6) + "" + ","
                + Util.limitDecimalPlaces(currentLocation.getLatitude(), 6) + ""
                + "&georef=EPSG:4326&outgeoref=EPSG:4326&login=ibikecph&password=Spoiledmilk123&hits=10";

        if (address.zip != null & !address.zip.equals("")) {
            urlString = urlString + "&postnr=" + address.zip;
        }
        if (address.city != null & !address.city.equals("") && !address.city.equals(address.street)) {
            // urlString = urlString + "&by=" + URLEncoder.encode(address.city.trim(), "UTF-8") + "*";
            urlString = urlString + "&postdist=*" + URLEncoder.encode(address.city.trim(), "UTF-8") + "*";
        }

        urlString += "&geometry=true";

        JsonNode rootNode = performGET(urlString);
        if (rootNode.has("features")) {
            JsonNode features = rootNode.get("features");
            for (int i = 0; i < features.size(); i++) {
                if (features.get(i).has("properties") && (features.get(i).get("properties").has("vej_navn")
                        || features.get(i).get("properties").has("navn")))
                    list.add(features.get(i));
            }
        }
    } catch (Exception e) {
        if (e != null && e.getLocalizedMessage() != null)
            LOG.e(e.getLocalizedMessage());
    }
    return list;
}

From source file:com.bigdata.diane.MiniTestDFSIO.java

private static void createControlFile(FileSystem fs, int fileSize, // in MB 
        int nrFiles, Configuration fsConfig) throws InterruptedException, IOException {
    LOG.info("creating control file: " + fileSize + " mega bytes, " + nrFiles + " files");

    for (int i = 0; i < nrFiles; i++) {
        String name = getFileName(i);
        Path controlFile = new Path(CONTROL_DIR, "in_file_" + name);
        SequenceFile.Writer writer = null;
        try {//from   w w  w.  ja  v a 2  s  . c  om
            writer = SequenceFile.createWriter(fs, fsConfig, controlFile, Text.class, LongWritable.class,
                    CompressionType.NONE);
            writer.append(new Text(name), new LongWritable(fileSize));
        } catch (Exception e) {
            throw new IOException(e.getLocalizedMessage());
        } finally {
            if (writer != null)
                writer.close();
            writer = null;
        }
    }
    LOG.info("created control files for: " + nrFiles + " files now sleep 20 seconds");
    Thread.sleep(20000);
}

From source file:com.mohawk.webcrawler.ScriptCompiler.java

/**
 *
 * @param tokens//from  w w  w  . j av  a2s  .c o  m
 * @param parentScope
 */
private static void addScope(Queue<String> tokens, Queue<? super BaseToken> parentScope)
        throws CompilationException {

    while (!tokens.isEmpty()) {

        String token = tokens.poll();
        if ("end".equals(token) || "else".equals(token) || "elseif".equals(token)) {
            parentScope.add(new BaseEndScope(token));
            break;
        } else if ("if".equals(token)) {
            String expression = tokens.poll();

            If_Verb ifVerb = new If_Verb();
            ifVerb.setExpression(expression);

            parentScope.add(ifVerb);
            addScope(tokens, ifVerb.createScope());

            // check if elseif or else is defined
            LinkedList<BaseToken> ifScope = ifVerb.getScope();
            Object elseToken = ifScope.peekLast();

            if (elseToken instanceof BaseEndScope) {
                // remove elseif or else from if scope
                ifScope.pollLast();

                while (elseToken instanceof BaseEndScope) {

                    String elseStr = ((BaseEndScope) elseToken).getName();
                    if ("end".equals(elseStr))
                        break;
                    else if ("elseif".equals(elseStr)) {

                        String exp = tokens.poll();
                        ElseIf_Verb elseIfVerb = new ElseIf_Verb();
                        elseIfVerb.setExpression(exp);
                        ifVerb.addElseIf(elseIfVerb);

                        addScope(tokens, elseIfVerb.createScope());
                        elseToken = elseIfVerb.getScope().pollLast();
                    } else if ("else".equals(elseStr)) {

                        Else_Verb elseVerb = new Else_Verb();
                        ifVerb.setElse(elseVerb);

                        addScope(tokens, elseVerb.createScope());
                        elseToken = elseVerb.getScope().pollLast();
                    }
                }
            }
        } else if ("while".equals(token)) {

            String evaluation = tokens.poll();

            While_Verb whileVerb = new While_Verb();
            whileVerb.setExpression(evaluation);

            parentScope.add(whileVerb);
            addScope(tokens, whileVerb.createScope());
        } else if (LangCore.isVerb(token)) { // verb
            try {
                parentScope.add(LangCore.createVerbToken((String) token));
            } catch (Exception e) {
                e.printStackTrace();
                throw new CompilationException(e.getLocalizedMessage());
            }
        } else if (LangCore.isLiteral(token)) { // literal
            try {
                parentScope.add(new BaseLiteral(LangCore.createLiteralObject(token)));
            } catch (LanguageException e) {
                throw new CompilationException(e.getLocalizedMessage());
            }
        } else if (LangCore.isOperator(token)) { // operator
            try {
                parentScope.add(LangCore.createOperatorToken(token));
            } catch (LanguageException e) {
                throw new CompilationException(e.getLocalizedMessage());
            }
        } else // default to variable
            parentScope.add(new BaseVariable(token));
    }
}

From source file:com.melani.utils.ProjectHelpers.java

public static String parsearCaracteresEspecialesXML1(String xmlaParsear) {
    String xml = "No paso Nada";
    StringBuilder sb = null;/*from  w  ww  .  j  a  v  a2s  . c  om*/
    try {

        sb = new StringBuilder(xmlaParsear);
        if (xmlaParsear.indexOf("<item>") != -1) {
            xml = StringEscapeUtils.escapeXml10(
                    xmlaParsear.substring(xmlaParsear.indexOf("nes>") + 4, xmlaParsear.indexOf("</obse")));
            sb.replace(sb.indexOf("nes>") + 4, sb.indexOf("</obse"), xml);
        }
        if (xmlaParsear.indexOf("<Domicilio>") != -1) {
            xml = StringEscapeUtils.escapeXml10(
                    xmlaParsear.substring(xmlaParsear.indexOf("mes>") + 4, xmlaParsear.indexOf("</det1")));
            sb.replace(sb.indexOf("mes>") + 4, sb.indexOf("</det1"), xml);
        }
        xml = sb.toString();

    } catch (Exception e) {
        xml = "Error";
        logger.error("Error en metodo parsearCaracteresEspecialesXML1 " + e.getLocalizedMessage());
    } finally {
        return xml;
    }
}

From source file:edu.harvard.mcz.imagecapture.ImageCaptureApp.java

/**
 * Initiate actions to be taken on shutting down the application.
 */// w  w  w.  j a  v  a  2  s  . co  m
public static void cleanUp() {
    try {
        Singleton.getSingletonInstance().getProperties().saveProperties();
    } catch (Exception e) {
        System.out.println("Properties file save failed.  " + e.getLocalizedMessage());
    }
}

From source file:com.jkoolcloud.tnt4j.streams.configure.zookeeper.ZKConfigInit.java

/**
 * Loads uploader configuration and runs uploading process.
 * /*  w  w w  . j a  va2s . c  om*/
 * @param cfgFileName
 *            uploader configuration file path
 */
private static void loadConfigAndRun(String cfgFileName) {
    if (StringUtils.isEmpty(cfgFileName)) {
        LOGGER.log(OpLevel.ERROR, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                "ZKConfigInit.upload.cfg.not.defined"));
        return;
    }

    Properties zkup = ZKConfigManager.readStreamsZKConfig(cfgFileName);

    if (MapUtils.isNotEmpty(zkup)) {
        try {
            ZKConfigManager.openConnection(zkup);

            String streamsPath = zkup.getProperty(ZKConfigManager.PROP_ZK_STREAMS_PATH);
            Stat nodeStat = ZKConfigManager.zk().exists(streamsPath, false);

            if (clean && nodeStat != null) {
                LOGGER.log(OpLevel.INFO, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                        "ZKConfigInit.clearing.zk"), streamsPath);
                ZKUtil.deleteRecursive(ZKConfigManager.zk(), streamsPath);
            }

            byte[] cfgData;
            String cfgPath;

            for (Map.Entry<?, ?> pe : zkup.entrySet()) {
                String pk = (String) pe.getKey();
                String pv = (String) pe.getValue();

                if (!pk.startsWith("zk.")) { // NON-NLS
                    cfgData = loadDataFromFile(pv);
                    cfgPath = streamsPath + ZKConfigManager.PATH_DELIM
                            + pk.replaceAll("\\.", ZKConfigManager.PATH_DELIM); // NON-NLS
                    ZKConfigManager.setNodeData(ZKConfigManager.zk(), cfgPath, cfgData);
                }
            }
        } catch (Exception exc) {
            LOGGER.log(OpLevel.ERROR, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                    "ZKConfigInit.upload.error"), exc.getLocalizedMessage(), exc);
        } finally {
            ZKConfigManager.close();
        }
    }
}

From source file:jmupen.JMupenUpdater.java

public static void checkForUpdates() {
    try {/* w  w w. j  av  a  2 s.  co  m*/
        jarFile = getJarFile();
    } catch (URISyntaxException ex) {
        System.err.println("Error getting jarfile path. " + ex.getLocalizedMessage());
        return;
    }
    try {
        if (jarFile != null) {
            // Get URL connection and lastModified time
            URL url = new URL(JarURL);
            URLConnection connection = url.openConnection();
            long localMod = jarFile.lastModified(), onlineMod = connection.getLastModified();
            updatePackage = new File(
                    JMupenUtils.getConfigDir().concat(JMupenUtils.getBar()).concat("jmupen-update.jar"));

            if (updatePackage.exists()) {
                JMupenUpdater.setUpdateAvailable(true);
                JMupenGUI.getInstance().showUpdateDialog();
                return;
            }
            if (localMod >= onlineMod - tenmin) {
                System.out.println("No update available at " + JarURL + '(' + localMod + '>' + onlineMod + ')');
                JMupenUpdater.setUpdateAvailable(false);
                return;
            } else {
                JMupenUpdater.setUpdateAvailable(true);
            }

            System.out.println("Loading update from " + JarURL);
            byte bytes[] = getBytes(connection);
            System.out.println("Update loaded");
            writeBytes(updatePackage, bytes);
            System.out.println("Update saved: " + updatePackage.getAbsolutePath());

            jarFile.setLastModified(onlineMod);
            JMupenGUI.getInstance().showUpdateDialog();
        }
    } catch (Exception e) {
        System.err.println("Error updating JMupen. " + e.getLocalizedMessage());
    }
}

From source file:dk.kk.ibikecphlib.util.HttpUtils.java

public static JsonNode getFromServer(String urlString) {
    JsonNode ret = null;//ww  w.java2s.c om
    LOG.d("GET api request, url = " + urlString);
    HttpParams myParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(myParams, CONNECTON_TIMEOUT);
    HttpConnectionParams.setSoTimeout(myParams, CONNECTON_TIMEOUT);
    HttpClient httpclient = new DefaultHttpClient(myParams);
    httpclient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, Config.USER_AGENT);
    HttpGet httpget = null;
    URL url = null;
    try {

        url = new URL(urlString);
        httpget = new HttpGet(url.toString());
        httpget.setHeader("Content-type", "application/json");
        httpget.setHeader("Accept", ACCEPT);
        httpget.setHeader("LANGUAGE_CODE", IBikeApplication.getLanguageString());
        HttpResponse response = httpclient.execute(httpget);
        String serverResponse = EntityUtils.toString(response.getEntity());
        LOG.d("API response = " + serverResponse);
        ret = Util.stringToJsonNode(serverResponse);
    } catch (Exception e) {
        if (e != null && e.getLocalizedMessage() != null) {
            LOG.e(e.getLocalizedMessage());
        }
    }
    return ret;
}