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

protected static Result internalTransformWithParams(Reader doc, Templates templates, Result r, boolean trace,
        String[] params) {/*from  w  w w .j a v a  2 s .  c  o  m*/
    StringWriter sw = new StringWriter();

    try {
        Transformer transformer = templates.newTransformer();
        if (params != null && params.length > 0) {
            for (int i = 0; i < params.length; i++)
                transformer.setParameter("param_" + i, params[i]);
        }

        transformer.transform(new StreamSource(doc), r);

        sw.close();
        return r;
    } catch (Throwable th) {
        th.printStackTrace();
        return r;
    }

}

From source file:Main.java

public static String getProcessName(int pid) {
    BufferedReader reader = null;
    try {/* ww  w . j a  va 2  s  .  c om*/
        reader = new BufferedReader(new FileReader("/proc/" + pid + "/cmdline"));
        String processName = reader.readLine();
        if (!TextUtils.isEmpty(processName)) {
            processName = processName.trim();
        }
        return processName;
    } catch (Throwable throwable) {
        throwable.printStackTrace();
    } finally {
        try {
            if (reader != null) {
                reader.close();
            }
        } catch (IOException exception) {
            exception.printStackTrace();
        }
    }
    return null;
}

From source file:Main.java

public static void fixInputMethodManagerLeak(Context context) {
    if (context == null) {
        return;//from w  w  w . jav a  2  s.com
    }

    try {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm == null) {
            return;
        }

        Field f_mCurRootView = imm.getClass().getDeclaredField("mCurRootView");
        Field f_mServedView = imm.getClass().getDeclaredField("mServedView");
        Field f_mNextServedView = imm.getClass().getDeclaredField("mNextServedView");

        f_mCurRootView.setAccessible(true);
        f_mCurRootView.set(imm, null);

        f_mServedView.setAccessible(true);
        f_mServedView.set(imm, null);

        f_mNextServedView.setAccessible(true);
        f_mNextServedView.set(imm, null);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:Main.java

public static boolean isUpdateAvailable(Context paramContext, String paramString) {
    try {/*  ww w  .  j  av  a  2s .c  o m*/
        HttpURLConnection localHttpURLConnection = (HttpURLConnection) new URL(paramString).openConnection();
        long l1 = localHttpURLConnection.getHeaderFieldDate("Last-Modified", System.currentTimeMillis());
        localHttpURLConnection.disconnect();
        long l2 = PreferenceManager.getDefaultSharedPreferences(paramContext.getApplicationContext())
                .getLong(paramString, 0L);
        boolean toReturn = l1 > l2;

        return toReturn;
    } catch (Throwable localThrowable) {
        localThrowable.printStackTrace();
    }
    return false;
}

From source file:Main.java

/**
 * Get all threads//  ww w  .j a v a  2 s  . co m
 * 
 * @return
 */
public static String[] getThreadNames() {
    ThreadGroup group = Thread.currentThread().getThreadGroup();
    ThreadGroup parent = null;
    while ((parent = group.getParent()) != null) {
        group = parent;
    }
    Thread[] threads = new Thread[group.activeCount()];
    group.enumerate(threads);
    HashSet<String> set = new HashSet<String>();

    for (int i = 0; i < threads.length; ++i) {
        if (threads[i] != null && threads[i].isAlive()) {
            try {
                set.add(threads[i].getThreadGroup().getName() + ", " + threads[i].getName() + ", "
                        + threads[i].getPriority() + ", " + threads[i].getState());
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }
    }
    String[] result = (String[]) set.toArray(new String[0]);
    Arrays.sort(result);

    for (int i = 0; i < result.length; i++) {
        //         logger.debug(result[i]);
    }

    return result;
}

From source file:Main.java

protected static Result internalTransform(Document doc, Templates templates, Result r, boolean trace) {
    StringWriter sw = new StringWriter();

    try {/*from w w w  .j  ava2  s  . c om*/
        Transformer transformer = templates.newTransformer();

        transformer.transform(new DOMSource(doc), r);

        sw.close();
        return r;
    } catch (Throwable th) {
        th.printStackTrace();
        return r;
    }
}

From source file:Main.java

protected static Result internalTransform(InputStream doc, Templates templates, Result r, boolean trace) {
    StringWriter sw = new StringWriter();

    try {/*from w  w w. j a v a 2  s. co m*/
        Transformer transformer = templates.newTransformer();

        transformer.transform(new StreamSource(doc), r);

        sw.close();
        return r;
    } catch (Throwable th) {
        th.printStackTrace();
        return r;
    }

}

From source file:Main.java

protected static Result internalTransform(Reader doc, Templates templates, Result r, boolean trace) {
    StringWriter sw = new StringWriter();

    try {/*w  w w .  j  av  a  2  s  .  c om*/
        Transformer transformer = templates.newTransformer();

        transformer.transform(new StreamSource(doc), r);

        sw.close();
        return r;
    } catch (Throwable th) {
        th.printStackTrace();
        return r;
    }

}

From source file:com.quartz.monitor.core.QuartzConnectUtil.java

/**
 * util method for printing all methods an mbean has exposed.
 *
 * @param quartzInstance/*w  w w . j av a2  s  .c  o  m*/
 */
public static void printMBeanProperties(QuartzInstance quartzInstance, ObjectName objectName) {
    try {
        QuartzJMXAdapter adapter = quartzInstance.getJmxAdapter();
        adapter.printAttributes(quartzInstance, objectName);
        adapter.printConstructors(quartzInstance, objectName);
        adapter.printOperations(quartzInstance, objectName);
        adapter.printNotifications(quartzInstance, objectName);
        adapter.printClassName(quartzInstance, objectName);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:Main.java

public static boolean isValidEmail(String email) {
    try {/*  w ww  . j  av a 2s  . c om*/
        return android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches();
    } catch (Throwable t) {
        LOGE("isValidEmail failed: " + t.getMessage());
        t.printStackTrace();
        return false;
    }
}