List of usage examples for java.lang Throwable printStackTrace
public void printStackTrace()
From source file:Main.java
public static void fore(final Runnable r) { main.post(new Runnable() { @Override/* www .j a v a 2s . c o m*/ public void run() { try { r.run(); } catch (Throwable e) { e.printStackTrace(); } } }); }
From source file:Main.java
public static void backQueue(final Runnable r) { back.post(new Runnable() { @Override/* ww w. j a v a 2s .c o m*/ public void run() { try { r.run(); } catch (Throwable e) { e.printStackTrace(); } } }); }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T newInstance(@NonNull Class<T> cls) { final Constructor ctor = getDefaultConstructor(cls); try {/* w w w. j a v a2s . co m*/ return (T) ctor.newInstance(); } catch (Throwable t) { t.printStackTrace(); throw new RuntimeException("Failed to instantiate " + cls.getName() + ": " + t.getLocalizedMessage()); } }
From source file:Main.java
public static void addRunnable(final Runnable runnable) { initService();/*from w w w . j a v a 2 s.c o m*/ executorService.execute(new Runnable() { public void run() { try { runnable.run(); } catch (Throwable e) { e.printStackTrace(); } } }); }
From source file:Main.java
static public int callDrawGLFunction(Canvas canvas, long functor) { if (methodCallDrawGLFunctionInt != null) { try {/*from w w w . j a v a 2 s.c o m*/ Object result = methodCallDrawGLFunctionInt.invoke(canvas, (int) functor); return (Integer) result; } catch (Throwable t) { t.printStackTrace(); } } else if (methodCallDrawGLFunctionLong != null) { try { Object result = methodCallDrawGLFunctionLong.invoke(canvas, functor); return (Integer) result; } catch (Throwable t) { t.printStackTrace(); } } return 0; }
From source file:Main.java
/** * Gets the operating system type.//from w w w .j a va2 s . com * * @return OS_WINDOWS, OS_MACINTOSH, or OS_OTHER */ public static int getOperatingSystem() { // Get the operating system name. String osName = ""; try { osName = System.getProperty("os.name"); } catch (Throwable t) { t.printStackTrace(); } // Convert to one of the operating system constants. int os = OS_OTHER; if (osName.toLowerCase().indexOf("windows") >= 0) { os = OS_WINDOWS; } else if (osName.startsWith("Mac OS X")) { os = OS_MACINTOSH; } return os; }
From source file:Main.java
public static byte[] DESTemplet(byte[] data, byte[] key, String algorithm, String transformation, boolean isEncrypt) { try {/*from w ww . j a v a 2s. com*/ SecretKeySpec keySpec = new SecretKeySpec(key, algorithm); Cipher cipher = Cipher.getInstance(transformation); SecureRandom random = new SecureRandom(); cipher.init(isEncrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, keySpec, random); return cipher.doFinal(data); } catch (Throwable e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static byte[] desTemplate(byte[] data, byte[] key, String algorithm, String transformation, boolean isEncrypt) { if (data == null || data.length == 0 || key == null || key.length == 0) return null; try {/*from w w w.j a v a 2s . co m*/ SecretKeySpec keySpec = new SecretKeySpec(key, algorithm); Cipher cipher = Cipher.getInstance(transformation); SecureRandom random = new SecureRandom(); cipher.init(isEncrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE, keySpec, random); return cipher.doFinal(data); } catch (Throwable e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static void outputDebug(String pDebugStr, Throwable pThrowable) { outputDebug(pDebugStr); pThrowable.printStackTrace(); }
From source file:Main.java
public static Bitmap decodeSampledBitmapFromByteArray(byte[] bytes, long allowedBmpMaxMemorySize) { try {/* w w w. ja va 2 s . c o m*/ final Options options = new Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options); options.inSampleSize = calculateInSampleSize(options, allowedBmpMaxMemorySize); options.inJustDecodeBounds = false; return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options); } catch (Throwable err) { err.printStackTrace(); } return null; }