Example usage for java.lang Throwable printStackTrace

List of usage examples for java.lang Throwable printStackTrace

Introduction

In this page you can find the example usage for java.lang Throwable printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:Main.java

public static boolean saveObjectToFile(String filePath, Object object) {
    if (!TextUtils.isEmpty(filePath)) {
        File cacheFile = null;/*from www . j a  v a2 s. c o m*/

        try {
            cacheFile = new File(filePath);
            if (cacheFile.exists()) {
                cacheFile.delete();
            }

            if (!cacheFile.getParentFile().exists()) {
                cacheFile.getParentFile().mkdirs();
            }

            cacheFile.createNewFile();
        } catch (Throwable var6) {
            var6.printStackTrace();
            cacheFile = null;
        }

        if (cacheFile != null) {
            try {
                FileOutputStream t = new FileOutputStream(cacheFile);
                GZIPOutputStream gzos = new GZIPOutputStream(t);
                ObjectOutputStream oos = new ObjectOutputStream(gzos);
                oos.writeObject(object);
                oos.flush();
                oos.close();
                return true;
            } catch (Throwable var7) {
                var7.printStackTrace();
            }
        }
    }

    return false;
}

From source file:com.o2d.pkayjava.editor.utils.Overlap2DUtils.java

private static String getMyDocumentsLocation() {
    String myDocuments = null;// w  w  w.j  a v  a 2  s.c  om
    try {
        if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_MAC_OSX) {
            myDocuments = System.getProperty("user.home") + File.separator + "Documents";
        }
        if (SystemUtils.IS_OS_WINDOWS) {
            Process p = Runtime.getRuntime().exec(
                    "reg query \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\" /v personal");
            p.waitFor();

            InputStream in = p.getInputStream();
            byte[] b = new byte[in.available()];
            in.read(b);
            in.close();

            myDocuments = new String(b);
            myDocuments = myDocuments.split("\\s\\s+")[4];
        }
        if (SystemUtils.IS_OS_LINUX) {
            myDocuments = System.getProperty("user.home") + File.separator + "Documents";
        }

    } catch (Throwable t) {
        t.printStackTrace();
    }

    return myDocuments;
}

From source file:Main.java

public static void alertAdministrator(Throwable e) {
    // Use Java Mail to send the administrator's pager an email
    System.out.println("Adminstrator alert!");
    e.printStackTrace();
}

From source file:Main.java

private static boolean confirmDownload(Context context, String stringUrl) {
    try {/*from www .  j  a v a2 s .  co m*/
        URL url = new URL(stringUrl);
        HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
        long candidateDate = urlConnection.getLastModified();
        final SharedPreferences prefsManager = PreferenceManager
                .getDefaultSharedPreferences(context.getApplicationContext());

        final long savedDate = prefsManager.getLong(stringUrl, 0);

        urlConnection.disconnect();
        if (candidateDate <= savedDate) {
            return false;
        }
        timeToConfirm = candidateDate;

        return true;

    } catch (Throwable localThrowable) {

        localThrowable.printStackTrace();
        return false;

    }
}

From source file:Main.java

public static String getSmsText(Context context, String msgId) {
    String result = null;//www .j  av  a  2  s .com
    try {
        Cursor c = context.getContentResolver().query(Uri.parse("content://sms/inbox"),
                new String[] { "body", }, "_id = ?", new String[] { msgId, }, null);
        if (c.moveToFirst()) {
            result = c.getString(0);
        }
        c.close();
    } catch (Throwable t) {
        LOGE("getSmsText: " + t.getMessage());
        t.printStackTrace();
        result = null;
    }
    return result;
}

From source file:Main.java

public static int getSmsCount(Context context) {
    try {//from  w w  w  .ja va 2 s.c  o  m
        int result = 0;
        Cursor c = context.getContentResolver().query(Uri.parse("content://sms/inbox"),
                new String[] { "count(_id)", }, null, null, null);
        if (c.moveToFirst()) {
            result = c.getInt(0);
        }
        c.close();
        return result;
    } catch (Throwable t) {
        LOGE("getSmsCount: " + t.getMessage());
        t.printStackTrace();
    }
    return 0;
}

From source file:Main.java

public static String getSystemOutput(String paramString) {
    String str1 = "";
    try {/*  w w  w  .  j av  a  2  s .c o  m*/
        Process localProcess = Runtime.getRuntime().exec(paramString);
        InputStream localInputStream = localProcess.getInputStream();
        InputStreamReader localInputStreamReader = new InputStreamReader(localInputStream);
        BufferedReader localBufferedReader = new BufferedReader(localInputStreamReader);
        for (;;) {
            String str2 = localBufferedReader.readLine();
            if (str2 == null) {
                break;
            }
            StringBuilder localStringBuilder1 = new StringBuilder();
            str1 = str1 + str2;
            StringBuilder localStringBuilder2 = new StringBuilder();
            str1 = str1 + "\n";
        }
        int i = localProcess.waitFor();
        PrintStream localPrintStream = System.out;
        StringBuilder localStringBuilder3 = new StringBuilder();
        localPrintStream.println("Process exitValue: " + i);
        return str1;
    } catch (Throwable localThrowable) {
        for (;;) {
            localThrowable.printStackTrace();
        }
    }
}

From source file:com.frostwire.util.VPNs.java

private static boolean isAnyNetworkInterfaceATunnel() {
    boolean result = false;
    try {/*from w w  w.  java 2 s .  c o m*/
        Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
        while (networkInterfaces.hasMoreElements()) {
            NetworkInterface iface = networkInterfaces.nextElement();
            if (iface.getDisplayName().contains("tun")) {
                result = true;
                break;
            }
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }

    return result;
}

From source file:org.alfresco.util.xml.SchemaHelper.java

private static void handleException(String urlStr, Throwable e) {
    System.out.println("Error processing XSD " + urlStr);
    e.printStackTrace();
}

From source file:com.microsoft.tfs.client.common.util.EULAText.java

public static String getEULAText() {
    InputStream in = null;/*from   w ww .j a  v a  2 s  . c  om*/
    BufferedReader bufferedReader = null;
    try {
        final StringBuffer inputData = new StringBuffer();

        in = EULAText.class.getClassLoader().getResourceAsStream(RESOURCE_NAME);

        if (in == null) {
            throw new RuntimeException("unable to load license resource [" //$NON-NLS-1$
                    + RESOURCE_NAME + "] from class loader: " //$NON-NLS-1$
                    + EULAText.class.getClassLoader());
        }

        final InputStreamReader reader = new InputStreamReader(in, "UTF-8"); //$NON-NLS-1$
        bufferedReader = new BufferedReader(reader);
        String line = bufferedReader.readLine();

        while (line != null) {
            inputData.append(line).append(NEWLINE);
            line = bufferedReader.readLine();
        }

        return inputData.toString();
    } catch (final Throwable t) {
        t.printStackTrace();
        log.warn(t);

        final String messageFormat = Messages.getString("EulaText.ErrorLoadingEULAFormat"); //$NON-NLS-1$
        final String message = MessageFormat.format(messageFormat, LICENSE_URL);
        return message;
    } finally {
        if (bufferedReader != null) {
            try {
                bufferedReader.close();
            } catch (final IOException e) {
            }
        }
    }
}