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:Main.java

public static Process deleteBuildProperty(Context c, String propName) {
    Process p = null;// w  w  w.j a  va  2  s  . co m
    try {
        remountSystem(c);

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

From source file:framework.classes.PoolConexion.java

/**
 * CONFIGURE CONNECTION// ww w .j  a  va2 s  . c  o m
 */
public static void iniciar_BasicDataSourceFactory() {
    Properties propiedades = new Properties();
    /*
    setMaxActive(): N mx de conexiones que se pueden abrir simultneamente.
    setMinIdle(): N mn de conexiones inactivas que queremos que haya. Si el n de conexiones baja de este n, se abriran ms.
    setMaxIdle(): N mx de conexiones inactivas que queremos que haya. Si hay ms, se irn cerrando.
    */
    propiedades.setProperty("driverClassName", "com.mysql.jdbc.Driver");
    propiedades.setProperty("url", "jdbc:mysql://127.0.0.1:3306/SQL_BD");
    propiedades.setProperty("maxActive", "10");
    propiedades.setProperty("maxIdle", "8");
    propiedades.setProperty("minIdle", "0");
    propiedades.setProperty("maxWait", "500");
    propiedades.setProperty("initialSize", "5");
    propiedades.setProperty("defaultAutoCommit", "true");
    propiedades.setProperty("username", "root");
    propiedades.setProperty("password", "root");
    propiedades.setProperty("validationQuery", "select 1");
    propiedades.setProperty("validationQueryTimeout", "100");
    propiedades.setProperty("initConnectionSqls", "SELECT 1;SELECT 2");
    propiedades.setProperty("poolPreparedStatements", "true");
    propiedades.setProperty("maxOpenPreparedStatements", "10");

    try {
        //propiedades.load(new FileInputStream("src/config/datasource_config.properties"));
        dataSource = (BasicDataSource) BasicDataSourceFactory.createDataSource(propiedades);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e.toString());
    }
}

From source file:net.longfalcon.newsj.util.DateUtil.java

public static DateTime parseAirDate(String airDateString) {
    DateTime dateTime = null;//from  w  w w.j  a v  a 2  s  . c o m

    try {
        dateTime = airDateFormatter.parseDateTime(airDateString);
    } catch (Exception e) {
        _log.debug(e.toString());
        try {
            dateTime = airDateFormatter_2.parseDateTime(airDateString);
        } catch (Exception e2) {
            _log.error(e2.toString());
        }
    }

    return dateTime;
}

From source file:Main.java

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

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

From source file:Main.java

public static boolean writeFile(String filePath, String fileName, String content, boolean append) {
    FileWriter fileWriter = null;
    boolean result = false;
    if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
        try {/*from w  w w .  j ava2s  . c o  m*/

            File file = new File(filePath);
            if (!file.exists()) {
                file.mkdirs();
            }
            Log.i("file", filePath);
            fileWriter = new FileWriter(filePath + fileName, append);
            fileWriter.write(content);
            result = true;
        } catch (Exception e) {
            e.printStackTrace();
            Log.i("file", e.toString());
        } finally {
            if (fileWriter != null) {
                try {
                    fileWriter.close();
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
    }
    return result;
}

From source file:erainformatica.utility.JSONHelper.java

public static TelegramRequestResult<JSONObject> readJsonFromUrl(String url) {
    InputStream is = null;/*from  ww w . jav a 2 s  .  c o  m*/
    try {
        is = new URL(url).openStream();
        return readJsonFromInputStream(is);
    } catch (Exception e) {
        return new TelegramRequestResult<>(false, e.toString(), null);
    }
}

From source file:framework.classes.connectionDB.java

public static void init_BasicDataSourceFactory() {
    Properties propiedades = new Properties();
    /*/*ww w . java  2s.c  o m*/
    setMaxActive(): N mx de conexiones que se pueden abrir simultneamente.
    setMinIdle(): N mn de conexiones inactivas que queremos que haya. Si el n de conexiones baja de este n, se abriran ms.
    setMaxIdle(): N mx de conexiones inactivas que queremos que haya. Si hay ms, se irn cerrando.
    */
    propiedades.setProperty("driverClassName", "com.mysql.jdbc.Driver");
    propiedades.setProperty("url", "jdbc:mysql://localhost:3306/app");
    propiedades.setProperty("maxActive", "10");
    propiedades.setProperty("maxIdle", "8");
    propiedades.setProperty("minIdle", "0");
    propiedades.setProperty("maxWait", "500");
    propiedades.setProperty("initialSize", "5");
    propiedades.setProperty("defaultAutoCommit", "true");
    propiedades.setProperty("username", "root");
    propiedades.setProperty("password", "root");
    propiedades.setProperty("validationQuery", "select 1");
    propiedades.setProperty("validationQueryTimeout", "100");
    propiedades.setProperty("initConnectionSqls", "SELECT 1;SELECT 2");
    propiedades.setProperty("poolPreparedStatements", "true");
    propiedades.setProperty("maxOpenPreparedStatements", "10");

    try {

        dataSource = (BasicDataSource) BasicDataSourceFactory.createDataSource(propiedades);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e.toString());
    }
}

From source file:com.wbtech.ums.common.NetworkUitlity.java

public static String Post(String url, String data) {

    CommonUtil.printLog("ums", url);

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(url);
    try {/*from   w  w w  . j av  a  2s.co  m*/
        StringEntity se = new StringEntity("content=" + data, HTTP.UTF_8);
        CommonUtil.printLog("postdata", "content=" + data);
        se.setContentType("application/x-www-form-urlencoded");
        httppost.setEntity(se);
        HttpResponse response = httpclient.execute(httppost);
        int status = response.getStatusLine().getStatusCode();
        CommonUtil.printLog("ums", status + "");
        String returnXML = EntityUtils.toString(response.getEntity());
        Log.d("returnString", URLDecoder.decode(returnXML));
        return URLDecoder.decode(returnXML);

    } catch (Exception e) {
        CommonUtil.printLog("ums", e.toString());
    }
    return null;
}

From source file:erainformatica.utility.JSONHelper.java

private static TelegramRequestResult<String> readAll(Reader rd) {
    try {/*from   w w  w .  j a v  a  2 s  .c  o m*/
        StringBuilder sb = new StringBuilder();
        int cp;
        while ((cp = rd.read()) != -1) {
            sb.append((char) cp);
        }
        return new TelegramRequestResult<>(true, null, sb.toString());
    } catch (Exception e) {
        return new TelegramRequestResult<>(true, e.toString(), null);
    }
}

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

/**
 * return hash value of string/* www. j a v  a 2  s.  c om*/
 *
 * @param str  unhashed string
 * @param salt salt for hash
 * @return hash value of string
 */
public static String hash(String str, String salt) {
    String hash = null;
    try {
        MessageDigest md = MessageDigest.getInstance("SHA-256");
        if (StringUtils.isNotEmpty(salt)) {
            md.update(Base64.decodeBase64(salt.getBytes()));
        }
        md.update(str.getBytes("UTF-8"));
        hash = new String(Base64.encodeBase64(md.digest()));
    } catch (Exception e) {
        log.error(e.toString(), e);
    }
    return hash;
}