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:org.wso2.cdm.agent.proxy.ServerApiAccess.java

public static HttpClient getCertifiedHttpClient() {
    try {// w  ww .  ja  v a  2s. c  o m
        HttpClient client = null;
        if (CommonUtilities.SERVER_PROTOCOL.equalsIgnoreCase("https://")) {
            KeyStore localTrustStore = KeyStore.getInstance("BKS");
            InputStream in = IdentityProxy.getInstance().getContext().getResources()
                    .openRawResource(R.raw.emm_truststore);
            localTrustStore.load(in, CommonUtilities.TRUSTSTORE_PASSWORD.toCharArray());

            SchemeRegistry schemeRegistry = new SchemeRegistry();
            schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
            SSLSocketFactory sslSocketFactory = new SSLSocketFactory(localTrustStore);
            sslSocketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
            schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));
            HttpParams params = new BasicHttpParams();
            ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);

            client = new DefaultHttpClient(cm, params);

        } else {
            client = new DefaultHttpClient();
        }
        return client;
    } catch (Exception e) {
        Log.d(TAG, e.toString());
        return null;
    }
}

From source file:com.psiphon3.psiphonlibrary.WebViewProxySettings.java

@SuppressWarnings("rawtypes")
private static boolean setWebkitProxyICS(Context ctx, String host, int port) {
    try {/*www .  ja  va2  s.  c  om*/
        Class webViewCoreClass = Class.forName("android.webkit.WebViewCore");

        Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
        if (webViewCoreClass != null && proxyPropertiesClass != null) {
            Method m = webViewCoreClass.getDeclaredMethod("sendStaticMessage", Integer.TYPE, Object.class);
            Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE, String.class);

            if (m != null && c != null) {
                m.setAccessible(true);
                c.setAccessible(true);
                Object properties = c.newInstance(host, port, null);

                // android.webkit.WebViewCore.EventHub.PROXY_CHANGED = 193;
                m.invoke(null, 193, properties);
                return true;
            }
        }
    } catch (Exception e) {
        MyLog.d("Exception setting WebKit proxy through android.webkit.Network: " + e.toString());
    } catch (Error e) {
        MyLog.d("Exception setting WebKit proxy through android.webkit.Network: " + e.toString());
    }

    return false;
}

From source file:com.syaku.commons.DateUtils.java

/**
* @method : setTime(parameter)//from   w ww . j  av  a2 s .c  om
* @brief :   Date  .
* @parameters {
parameter : (String) 
    }
* @return : (Date)
*/
public static Date setTime(String time) {
    Date retDate = null;
    try {
        time = time("HH:mm:ss", time);
        formatter = new SimpleDateFormat("HH:mm:ss");
        retDate = formatter.parse(time);
    } catch (Exception e) {
        log.error("[#MEI DateUtils.setTime] " + e.toString());
    }
    return retDate;
}

From source file:com.syaku.commons.DateUtils.java

/**
* @method : setDate(parameter)/*from w w  w  . jav a  2s .c  o  m*/
* @brief :   Date  .
* @parameters {
parameter : (String) 
    }
* @return : (Date)
*/
public static Date setDate(String date) {
    Date retDate = null;
    try {
        date = date("yyyy-MM-dd HH:mm:ss", date);
        formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        retDate = formatter.parse(date);
    } catch (Exception e) {
        log.error("[#MEI DateUtils.setDate] " + e.toString());
    }

    return retDate;
}

From source file:com.aliyun.android.oss.http.OSSHttpTool.java

/**
 * ??????//w  ww.  j  a  v  a  2  s . c  o  m
 */
public static String generateAuthorization(String accessId, String accessKey, String content) {
    String signature = null;
    try {
        signature = Helper.getHmacSha1Signature(content, accessKey);
    } catch (Exception e) {
        Log.i("authorization", e.toString());
    }
    return "OSS " + accessId + ":" + signature;
}

From source file:io.github.data4all.handler.TagSuggestionHandler.java

/**
 * //from   w w  w  . j a  v  a  2s . c o  m
 * @param url
 * @return the JSONObject from an url
 */
private static JSONObject getJSONfromURL(String url) {

    // initialize
    InputStream is = null;
    String address = "";
    JSONObject jObject = null;

    // http post
    try {
        final HttpClient httpclient = new DefaultHttpClient();
        httpclient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, System.getProperty("http.agent"));
        final HttpGet httppost = new HttpGet(url);
        final HttpResponse response = httpclient.execute(httppost);
        final 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 {
        final BufferedReader reader = new BufferedReader(new InputStreamReader(is, "utf-8"), 8);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
        is.close();
        address = sb.toString();
    } catch (Exception e) {
        Log.e("log_tag", "Error converting address " + e.toString());
    }

    // try parse the string to a JSON object
    try {
        jObject = new JSONObject(address);
    } catch (JSONException e) {
        Log.e("log_tag", "Error parsing data [" + e.getMessage() + "] " + address);
    }
    return jObject;
}

From source file:com.syaku.commons.DateUtils.java

public static String date(String format, String date) {
    String string = null;// w  w  w.  j  a  v  a2 s .com

    try {
        if (StringUtils.isEmpty(format))
            format = "yyyy-MM-dd HH:mm:ss";
        if (StringUtils.isEmpty(date))
            return date;

        date = date.replaceAll("[^0-9]+", "");
        date = StringUtils.rightPad(date, 14, '0');
        date = date.replaceAll("(^[0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})",
                "$1-$2-$3 $4:$5:$6");
        formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date redate = formatter.parse(date);
        formatter = new SimpleDateFormat(format);
        string = formatter.format(redate);
    } catch (Exception e) {
        log.error("[#MEI DateUtils.date] " + e.toString());
    }

    return string;
}

From source file:gdt.data.grain.Locator.java

/**
   * Encode a string into the Base64 string.
   *  //from  w  w  w  .j av a 2 s. c om
   * @param text$ the original string. 
* @return  the encoded string.   
   */
public static String compressText(String text$) {
    try {

        byte[] ba = text$.getBytes();
        return Base64.encodeBase64String(ba);

    } catch (Exception e) {
        Logger.getLogger(Locator.class.getName()).severe(e.toString());
        return null;
    }
}

From source file:org.openmrs.module.report.util.FileUtils.java

public static String copyFile(String uploadDir, byte[] bytes, String fileName) {
    File dirPath = new File(uploadDir);
    if (!dirPath.exists()) {
        dirPath.mkdirs();//from w  ww  . jav  a  2 s  . c  o m
    }
    String sep = System.getProperty("file.separator");
    File uploadedFile = new File(uploadDir + sep + fileName);
    try {
        //              if(!uploadedFile.exists())
        FileCopyUtils.copy(bytes, uploadedFile);
    } catch (Exception e) {
        // TODO: handle exception
        log.error("copyFile: " + e.toString());
        return "";
    }

    return fileName;
    // set success message
    // String url = request.getContextPath() + ConfigurationService.get(MyConst.VN_MUSIC_PATH_PICTURE,"/upload/vn_music/picture/")+ filename;
}

From source file:gdt.data.entity.BaseHandler.java

/**
 * List all databases in the parent directory
 *  @param entiroot$ the parent directory.
 * @return The locator string./*from w ww  . j a va  2  s .c o  m*/
 */
public static String[] bases(String entiroot$) {
    try {
        if (entiroot$ == null)
            return null;
        File entiroot = new File(entiroot$);
        File[] dirs = entiroot.listFiles();
        if (dirs == null)
            return null;
        File propertyIndex;
        Stack<String> s = new Stack<String>();
        for (int i = 0; i < dirs.length; i++) {
            if (!dirs[i].isDirectory())
                continue;
            propertyIndex = new File(dirs[i] + "/" + Entigrator.PROPERTY_INDEX);
            if (propertyIndex.exists() && propertyIndex.isFile())
                s.push(dirs[i].getPath());

        }
        int cnt = s.size();
        if (cnt < 1)
            return null;
        String[] sa = new String[cnt];
        for (int i = 0; i < cnt; i++)
            sa[i] = (String) s.pop();
        return sa;
    } catch (Exception e) {
        Logger.getLogger(BaseHandler.class.getName()).severe(e.toString());
        ;
        return null;
    }
}