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(Throwable cause) 

Source Link

Document

Constructs a new runtime exception with the specified cause and a detail message of (cause==null ?

Usage

From source file:Main.java

public static byte[] encode8bitUserData(String text) {
    try {// w  ww .  j a  v  a  2  s.  co  m
        return text.getBytes("ISO8859_1");
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:Main.java

public static int createProgram(int vsh, int fsh, String... attributes) {
    int[] status = new int[1];
    int ph = GLES20.glCreateProgram();
    if (ph <= 0) {
        throw new RuntimeException("Could not create program");
    }//from  w w  w.ja va 2  s . com
    GLES20.glAttachShader(ph, vsh);
    GLES20.glAttachShader(ph, fsh);
    for (int i = 0; i < attributes.length; ++i) {
        GLES20.glBindAttribLocation(ph, i, attributes[i]);
    }
    GLES20.glLinkProgram(ph);
    GLES20.glGetProgramiv(ph, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        GLES20.glDeleteProgram(ph);
        throw new RuntimeException("Could not link program");
    }

    return ph;
}

From source file:Main.java

public static ZipFile newZipFile(File file) {
    try {/*  w w  w.jav  a2s .c o m*/
        return new ZipFile(file);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:Main.java

public static String getTheOnlyElementOf(Set<String> set) {
    if (set.size() != 1) {
        throw new RuntimeException("Expected a set of one element"); //$NON-NLS-1$
    }/*from  w  ww. j av a  2  s .c  om*/
    return set.toArray(new String[1])[0];
}

From source file:Main.java

public static java.lang.String[] split(java.lang.String text, java.util.regex.Pattern pattern) {
    throw new RuntimeException("Stub!");
}

From source file:Main.java

static int hexCharToInt(char c) {
    if (c >= '0' && c <= '9')
        return (c - '0');
    if (c >= 'A' && c <= 'F')
        return (c - 'A' + 10);
    if (c >= 'a' && c <= 'f')
        return (c - 'a' + 10);

    throw new RuntimeException("invalid hex char '" + c + "'");
}

From source file:Main.java

public static void closeQietly(ZipFile zipFile) {
    try {//  w  ww .  ja va2s .co m
        zipFile.close();
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:Main.java

public static <E> E getOnlyElement(Iterable<E> iterable) {
    Iterator<E> iterator = iterable.iterator();

    if (!iterator.hasNext()) {
        throw new RuntimeException("Collection is empty");
    }/*from w w w  .  j  av a2 s.c om*/

    E element = iterator.next();

    if (iterator.hasNext()) {
        throw new RuntimeException("Collection contains more than one item");
    }

    return element;
}

From source file:Main.java

public static final String decodeURL(String str) {
    try {//from w  w  w .  j  a va 2  s .  com
        return URLDecoder.decode(str, "utf-8");
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
}

From source file:Main.java

public static java.lang.String join(java.lang.CharSequence delimiter, java.lang.Iterable tokens) {
    throw new RuntimeException("Stub!");
}