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:Main.java

public static void save(String filename, Document document) throws IOException {
    PrintStream out = null;//from  w w w.j a  va  2 s  . com
    try {
        out = new PrintStream(new BufferedOutputStream(new FileOutputStream(filename)), true, "UTF-8");
        //traceNode(document, "");
        print(out, document);
    } catch (Exception ex) {
        throw new IOException(ex.getLocalizedMessage());
    } finally {
        if (out != null)
            try {
                out.close();
            } catch (Exception e) {
                // ignore
            }
    }
}

From source file:com.spoiledmilk.cykelsuperstier.break_rote.STrainData.java

private static boolean isFridaySaturdayNight(JsonNode jsonNode, int hour) {
    boolean ret = false;
    try {/*  w  ww.j a  va  2 s  .c o  m*/
        String nightString = jsonNode.get("departure").get(0).get("night").asText();
        int startHour = Integer.parseInt((nightString.split(" ")[0]).split("\\.")[0]);
        int endHour = Integer.parseInt(
                (jsonNode.get("departure").get(0).get("night").asText().split(" ")[1]).split("\\.")[0]);
        if (hour >= startHour || hour < endHour)
            ret = true;
    } catch (Exception e) {
        LOG.e(e.getLocalizedMessage());
    }
    return ret;
}

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

private static void processLayoutFiles(String applicationPackage, File resTarget, File srcDir, File xmlDir,
        int minSdk, boolean isLibrary) {
    ArrayList<File> resourceFolders = new ArrayList<File>();
    resourceFolders.add(resTarget);/*from   w w  w.  j  ava  2s  .c om*/
    MakeFileWriter makeFileWriter = new MakeFileWriter(srcDir);
    LayoutXmlProcessor xmlProcessor = new LayoutXmlProcessor(applicationPackage, resourceFolders,
            makeFileWriter, minSdk, isLibrary);
    try {
        xmlProcessor.processResources(minSdk);
        xmlProcessor.writeLayoutInfoFiles(xmlDir);
        // TODO Looks like make does not support excluding from libs ?
        xmlProcessor.writeInfoClass(null, xmlDir, null);
        Map<String, List<LayoutFileBundle>> bundles = xmlProcessor.getResourceBundle().getLayoutBundles();
        if (isLibrary) {
            for (String name : bundles.keySet()) {
                LayoutFileBundle layoutFileBundle = bundles.get(name).get(0);
                String pkgName = layoutFileBundle.getBindingClassPackage().replace('.', '/');
                System.err.println(pkgName + '/' + layoutFileBundle.getBindingClassName() + ".class");
            }
        }
        if (makeFileWriter.getErrorCount() > 0) {
            System.exit(9);
        }
    } catch (Exception e) {
        System.err.println("Error processing layout files: " + e.getLocalizedMessage());
        System.exit(10);
    }
}

From source file:com.lineage.server.model.L1ItemDelay.java

/**
 * /*from   w  w  w .j  a  v  a  2  s  .  co m*/
 * 
 * @param client
 *            
 * @param item
 *            
 */
public static void onItemUse(final ClientThread client, final L1ItemInstance item) {
    try {
        final L1PcInstance pc = client.getActiveChar();
        if (pc != null) {
            onItemUse(pc, item);
        }

    } catch (final Exception e) {
        _log.error(e.getLocalizedMessage(), e);
    }
}

From source file:com.hybris.mobile.logging.ExceptionHandler.java

public static void submitStackTraces() {
    try {//from w w  w.  j av  a  2s  .  c o  m
        LoggingUtils.d(LOG_TAG, "Looking for exceptions in: " + RA.FILES_PATH);
        String[] list = searchForStackTraces();
        if (list != null && list.length > 0) {
            LoggingUtils.d(LOG_TAG, "Found " + list.length + " stacktrace(s)");
            for (int i = 0; i < list.length; i++) {
                String filePath = RA.FILES_PATH + "/" + list[i];
                // Extract the version from the filename: "packagename-version-...."
                String version = list[i].split("-")[0];
                LoggingUtils.d(LOG_TAG, "Stacktrace in file '" + filePath + "' belongs to version " + version);
                // Read contents of stacktrace
                StringBuilder contents = new StringBuilder();
                BufferedReader input = new BufferedReader(new FileReader(filePath));
                String line = null;
                String androidVersion = null;
                String phoneModel = null;
                while ((line = input.readLine()) != null) {
                    if (androidVersion == null) {
                        androidVersion = line;
                        continue;
                    } else if (phoneModel == null) {
                        phoneModel = line;
                        continue;
                    }
                    contents.append(line);
                    contents.append(System.getProperty("line.separator"));
                }
                input.close();
                String stacktrace;
                stacktrace = contents.toString();
                LoggingUtils.d(LOG_TAG, "Transmitting stack trace: " + stacktrace);
                // Transmit stack trace with POST request
                DefaultHttpClient httpClient = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost(RA.URL);
                List<NameValuePair> nvps = new ArrayList<NameValuePair>();
                nvps.add(new BasicNameValuePair("package_name", RA.APP_PACKAGE));
                nvps.add(new BasicNameValuePair("package_version", version));
                nvps.add(new BasicNameValuePair("phone_model", phoneModel));
                nvps.add(new BasicNameValuePair("android_version", androidVersion));
                nvps.add(new BasicNameValuePair("stacktrace", stacktrace));
                httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
                httpClient.execute(httpPost);
            }
        }
    } catch (Exception e) {
        LoggingUtils.e(LOG_TAG, "Error submitting stack traces. " + e.getLocalizedMessage(), null);
    } finally {
        String[] list = searchForStackTraces();
        for (int i = 0; i < list.length; i++) {
            File file = new File(RA.FILES_PATH + "/" + list[i]);
            file.delete();
        }
    }
}

From source file:com.lineage.server.model.L1ItemDelay.java

/**
 * //w w w.  j  ava2  s .co  m
 * 
 * @param pc
 *            
 * @param delayId
 *            ID<br>
 * <br>
 *            500:?<br>
 *            501:?<br>
 *            502:??<br>
 *            503:??<br>
 *            504:?<br>
 * @param delayTime
 *             ()
 */
public static void onItemUse(final L1PcInstance pc, final int delayId, final int delayTime) {
    try {
        if ((delayId != 0) && (delayTime != 0)) {
            final ItemDelayTimer timer = new ItemDelayTimer(pc, delayId, delayTime);

            pc.addItemDelay(delayId, timer);
            GeneralThreadPool.getInstance().schedule(timer, delayTime);
        }

    } catch (final Exception e) {
        _log.error(e.getLocalizedMessage(), e);
    }
}

From source file:com.spoiledmilk.cykelsuperstier.break_rote.STrainData.java

private static int[] getMinutesArray(String array) {
    int[] ret;//from   w  w  w  .  java 2s.com
    String[] splitted = array.split(" ");
    ret = new int[splitted.length];
    for (int i = 0; i < splitted.length; i++) {
        try {
            ret[i] = Integer.parseInt(splitted[i]);
        } catch (Exception e) {
            LOG.e(e.getLocalizedMessage());
        }
    }
    if (ret != null && ret.length > 0) {
        for (int j = 0; j < ret.length - 1; j++)
            for (int k = j + 1; k < ret.length; k++) {
                if (ret[j] > ret[k]) {
                    int temp = ret[j];
                    ret[j] = ret[k];
                    ret[k] = temp;
                }
            }
    }
    return ret;
}

From source file:pieShareAppITs.helper.ITUtil.java

public static void executeLoginToTestCloud(AnnotationConfigApplicationContext context, String cloudName,
        String password) throws Exception {
    LoginCommand command = new LoginCommand();
    PlainTextPassword pwd = new PlainTextPassword();
    pwd.password = password.getBytes();/*w  w w.  ja  va2 s . com*/
    command.setPlainTextPassword(pwd);
    command.setUserName(cloudName);

    command.setCallback(new ILoginFinished() {

        @Override
        public void error(Exception ex) {
            ex.printStackTrace();
            Assert.fail(ex.getLocalizedMessage());
        }

        @Override
        public void wrongPassword(WrongPasswordException ex) {
            Assert.fail(ex.getMessage());
        }

        @Override
        public void OK() {
        }
    });

    LoginTask task = context.getBean(LoginTask.class);
    task.setEvent(command);
    task.run();
}

From source file:com.nextgis.mobile.map.Layer.java

protected static String getFileNameByUri(final Context context, Uri uri, String defaultName) {
    String fileName = defaultName;
    Uri filePathUri = uri;//  w  ww  . ja v a 2 s  .  c  om
    try {
        if (uri.getScheme().toString().compareTo("content") == 0) {
            Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
            if (cursor.moveToFirst()) {
                int column_index = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
                //Instead of "MediaStore.Images.Media.DATA" can be used "_data"
                filePathUri = Uri.parse(cursor.getString(column_index));
                fileName = filePathUri.getLastPathSegment().toString();
            }
        } else if (uri.getScheme().compareTo("file") == 0) {
            fileName = filePathUri.getLastPathSegment().toString();
        } else {
            fileName = fileName + "_" + filePathUri.getLastPathSegment();
        }
    } catch (Exception e) {
        //do nothing, only return default file name;
        Log.d(TAG, e.getLocalizedMessage());
    }
    return fileName;
}

From source file:Main.java

public static void save(String filename, Document document) throws IOException {
    PrintStream out = null;//w ww  .  j  a v  a  2 s.  com
    try {
        out = new PrintStream(new BufferedOutputStream(new FileOutputStream(filename)), true, "UTF-8");
        // traceNode(document, "");
        print(out, document);
    } catch (Exception ex) {
        throw new IOException(ex.getLocalizedMessage());
    } finally {
        if (out != null)
            try {
                out.close();
            } catch (Exception e) {
                // ignore
            }
    }
}