Example usage for java.lang RuntimeException RuntimeException

List of usage examples for java.lang RuntimeException RuntimeException

Introduction

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

Prototype

public RuntimeException(String message, Throwable cause) 

Source Link

Document

Constructs a new runtime exception with the specified detail message and cause.

Usage

From source file:Main.java

public static String md5(String string) {

    byte[] hash;//from w  w  w  .j  ava 2 s. c om

    try {

        hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));

    } catch (NoSuchAlgorithmException e) {

        throw new RuntimeException("Huh, MD5 should be supported?", e);

    } catch (UnsupportedEncodingException e) {

        throw new RuntimeException("Huh, UTF-8 should be supported?", e);
    }

    StringBuilder hex = new StringBuilder(hash.length * 2);

    for (byte b : hash) {

        if ((b & 0xFF) < 0x10)
            hex.append("0");

        hex.append(Integer.toHexString(b & 0xFF));

    }

    return hex.toString();

}

From source file:Main.java

public static String md5(String string) {
    byte[] hash;//from   www  .ja  va  2s  .com

    try {
        hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException("Huh, MD5 should be supported?", e);
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException("Huh, UTF-8 should be supported?", e);
    }

    StringBuilder hex = new StringBuilder(hash.length * 2);

    for (byte b : hash) {
        int i = (b & 0xFF);
        if (i < 0x10)
            hex.append('0');
        hex.append(Integer.toHexString(i));
    }

    return hex.toString();
}

From source file:Main.java

public static String md5(String string) {
    byte[] hash = null;
    try {/*from www .ja v  a  2s . c  o  m*/
        hash = string.getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException("Huh,UTF-8 should be supported?", e);
    }
    return computeMD5(hash);
}

From source file:Main.java

public static void mkView(String viewTag) {
    try {//ww w.  ja  va  2s .com
        Process pr = Runtime.getRuntime().exec("cleartool mkview -tag " + viewTag + " \\\\"
                + InetAddress.getLocalHost().getHostName() + "\\viewstore\\" + viewTag + ".vws");
        pr.waitFor();
        pr.destroy();
    } catch (Exception e) {
        throw new RuntimeException("cleartool mkview error!", e);
    }
}

From source file:Main.java

public static XPathExpression getXPath(String expression) {
    try {//  w  ww  .  j  ava  2  s. c o m
        return getXPathFactory().newXPath().compile(expression);
    } catch (XPathExpressionException e) {
        throw new RuntimeException("Invalid XPath Expression " + expression, e);
    }
}