Example usage for java.lang Exception toString

List of usage examples for java.lang Exception toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:XMLUtil.java

public static void write(Document doc, OutputStream out) throws IOException {
    // XXX note that this may fail to write out namespaces correctly if the
    // document// w w  w.  j  av a  2s .  c  o m
    // is created with namespaces and no explicit prefixes; however no code in
    // this package is likely to be doing so
    try {
        Transformer t = TransformerFactory.newInstance().newTransformer();
        DocumentType dt = doc.getDoctype();
        if (dt != null) {
            String pub = dt.getPublicId();
            if (pub != null) {
                t.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, pub);
            }
            t.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, dt.getSystemId());
        }
        t.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // NOI18N
        t.setOutputProperty(OutputKeys.INDENT, "yes"); // NOI18N
        t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); // NOI18N
        Source source = new DOMSource(doc);
        Result result = new StreamResult(out);
        t.transform(source, result);
    } catch (Exception e) {
        throw (IOException) new IOException(e.toString()).initCause(e);
    } catch (TransformerFactoryConfigurationError e) {
        throw (IOException) new IOException(e.toString()).initCause(e);
    }
}

From source file:org.androidnerds.reader.util.api.Subscriptions.java

/**
 * This method queries Google Reader for the list of subscribed feeds.
 * //from  www. jav  a 2  s.  c  o m
 * @param sid authentication code to pass along in a cookie.
 * @return arr returns a JSONArray of JSONObjects for each feed.
 *
 * The JSONObject returned by the service looks like this:
 *    id: this is the feed url.
 *    title: this is the title of the feed.
 *    sortid: this has not been figured out yet.
 *    firstitemsec: this has not been figured out yet.
 */
public static JSONArray getSubscriptionList(String sid) {
    DefaultHttpClient client = new DefaultHttpClient();
    HttpGet get = new HttpGet(SUB_URL + "/list?output=json");
    BasicClientCookie cookie = Authentication.buildCookie(sid);

    try {
        client.getCookieStore().addCookie(cookie);

        HttpResponse response = client.execute(get);
        HttpEntity respEntity = response.getEntity();

        Log.d(TAG, "Response from server: " + response.getStatusLine());

        InputStream in = respEntity.getContent();
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));

        String line = "";
        String arr = "";
        while ((line = reader.readLine()) != null) {
            arr += line;
        }

        JSONObject obj = new JSONObject(arr);
        JSONArray array = obj.getJSONArray("subscriptions");

        reader.close();
        client.getConnectionManager().shutdown();

        return array;
    } catch (Exception e) {
        Log.d(TAG, "Exception caught:: " + e.toString());
        return null;
    }
}

From source file:com.linkedin.d2.discovery.stores.glu.TrustingSocketFactory.java

private static SSLContext createEasySSLContext() {
    try {// w w w. ja  v  a2  s  . com
        SSLContext context = SSLContext.getInstance("SSL");
        context.init(null, new TrustManager[] { new X509TrustManager() {
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                return null;
            }

            public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
            }

            public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
            }
        } }, null);
        return context;
    } catch (Exception e) {
        throw new HttpClientError(e.toString());
    }
}

From source file:Main.java

public static Process writeBuildProperty(Context c, String propName, String value) {
    Process p = null;//from  ww w .  j av  a  2  s  . c  o m
    try {
        remountSystem(c);

        p = runSuCommandAsync(c, "echo " + propName + "=" + value + " >> /system/build.prop ; ");
        Log.d("Helper", "echo " + propName + "=" + value + " >> /system/build.prop ; ");
        p.waitFor();
    } catch (Exception d) {
        Log.e("Helper", "Failed to write build.prop. errcode:" + d.toString());
    }
    return p;
}

From source file:com.ec2box.manage.util.EncryptionUtil.java

/**
 * return decrypted value of encrypted string
 *
 * @param str encrypted string/*from  ww w  . j a  v a2s. co m*/
 * @return decrypted string
 */
public static String decrypt(String str) {
    String retVal = null;
    if (str != null && str.length() > 0) {
        try {
            Cipher c = Cipher.getInstance("AES");
            c.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"));
            byte[] decodedVal = Base64.decodeBase64(str.getBytes());
            retVal = new String(c.doFinal(decodedVal));
        } catch (Exception ex) {
            log.error(ex.toString(), ex);
        }

    }
    return retVal;
}

From source file:com.quietlycoding.android.reader.util.api.Subscriptions.java

/**
 * This method queries Google Reader for the list of subscribed feeds.
 * //from   w  w  w .  j a v a 2s . co  m
 * @param sid
 *            authentication code to pass along in a cookie.
 * @return arr returns a JSONArray of JSONObjects for each feed.
 * 
 *         The JSONObject returned by the service looks like this: id: this
 *         is the feed url. title: this is the title of the feed. sortid:
 *         this has not been figured out yet. firstitemsec: this has not
 *         been figured out yet.
 */
public static JSONArray getSubscriptionList(String sid) {
    final DefaultHttpClient client = new DefaultHttpClient();
    final HttpGet get = new HttpGet(SUB_URL + "/list?output=json");
    final BasicClientCookie cookie = Authentication.buildCookie(sid);

    try {
        client.getCookieStore().addCookie(cookie);

        final HttpResponse response = client.execute(get);
        final HttpEntity respEntity = response.getEntity();

        Log.d(TAG, "Response from server: " + response.getStatusLine());

        final InputStream in = respEntity.getContent();
        final BufferedReader reader = new BufferedReader(new InputStreamReader(in));

        String line = "";
        String arr = "";
        while ((line = reader.readLine()) != null) {
            arr += line;
        }

        final JSONObject obj = new JSONObject(arr);
        final JSONArray array = obj.getJSONArray("subscriptions");

        reader.close();
        client.getConnectionManager().shutdown();

        return array;
    } catch (final Exception e) {
        Log.d(TAG, "Exception caught:: " + e.toString());
        return null;
    }
}

From source file:com.ec2box.manage.util.EncryptionUtil.java

/**
 * return encrypted value of string/*  ww  w .  j  av  a 2s.  c om*/
 *
 * @param str unencrypted string
 * @return encrypted string
 */
public static String encrypt(String str) {

    String retVal = null;
    if (str != null && str.length() > 0) {
        try {
            Cipher c = Cipher.getInstance("AES");
            c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"));
            byte[] encVal = c.doFinal(str.getBytes());
            retVal = new String(Base64.encodeBase64(encVal));
        } catch (Exception ex) {
            log.error(ex.toString(), ex);
        }

    }
    return retVal;
}

From source file:Main.java

public static Process writeBuildProperty(Context c, String propName, String value) {
    Process p = null;//from  w w w . j  a v  a 2  s.c o m
    try {
        remountSystem(c);

        p = runSuCommandAsync(c, "echo " + propName + "=" + value + " >> /system/build.prop");
        Log.d("Helper", "echo " + propName + "=" + value + " >> /system/build.prop");
        p.waitFor();
    } catch (Exception d) {
        Log.e("Helper", "Failed to write build.prop. errcode:" + d.toString());
    }
    return p;
}

From source file:com.matze5800.paupdater.JSONfunctions.java

public static JSONObject getJSONfromURL(String url) {

    InputStream is = null;/*  w w w. j av  a  2s .  co m*/
    String result = "";
    JSONObject jArray = null;

    //http post
    try {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(url);
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        is = entity.getContent();

    } catch (Exception e) {
        Log.e("log_tag", "Error in http connection " + e.toString());

    }

    //convert response to string
    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
        is.close();
        result = sb.toString();
    } catch (Exception e) {
        Log.e("log_tag", "Error converting result " + e.toString());
    }

    try {

        jArray = new JSONObject(result);
    } catch (JSONException e) {
        Log.e("log_tag", "Error parsing data " + e.toString());
    }

    return jArray;
}

From source file:Main.java

public static Process changeBuildProperty(Context c, String propName, String newValue) {
    Process p = null;//from  w  w  w.j av a2 s .  c o m
    try {
        remountSystem(c);

        p = runSuCommandAsync(c, "busybox sed -i \"s/" + propName + "=.*/" + propName + "=" + newValue
                + "/g\" /system/build.prop");
        p.waitFor();
    } catch (Exception d) {
        Log.e("Helper", "Failed to change build.prop. errcode:" + d.toString());
    }
    return p;
}