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:at.riemers.velocity2js.velocity.Velocity2Js.java

public static List<I18NBundle> getBundles(String resource) {
    List<I18NBundle> bundles = new ArrayList<I18NBundle>();
    if (resource != null) {
        try {// w w w .  ja va2  s  . c o  m
            File rb = new File(resource);
            String rbDirName = rb.getParent();
            String resourceName = rb.getName();
            //log("[velocity2js] - " + resourceName);
            if (rbDirName == null) {
                rbDirName = ".";
            }
            File rbDir = new File(rbDirName);
            String[] files = rbDir.list(new PropertiesFilter(resourceName));
            for (String file : files) {
                bundles.add(new I18NBundle(rbDirName, file));
            }
        } catch (Exception ex) {
            log.error("[velocity2js] - " + ex.toString(), ex);
        }
    } else {
        bundles.add(new I18NBundle());
    }
    return bundles;
}

From source file:com.keybox.manage.db.ProfileDB.java

/**
 * returns profile based on id// ww  w. j  a  v a 2s. com
 *
 * @param con db connection object
 * @param profileId profile id
 * @return profile
 */
public static Profile getProfile(Connection con, Long profileId) {

    Profile profile = null;
    try {
        PreparedStatement stmt = con.prepareStatement("select * from profiles where id=?");
        stmt.setLong(1, profileId);
        ResultSet rs = stmt.executeQuery();

        while (rs.next()) {
            profile = new Profile();
            profile.setId(rs.getLong("id"));
            profile.setNm(rs.getString("nm"));
            profile.setDesc(rs.getString("desc"));
            profile.setHostSystemList(ProfileSystemsDB.getSystemsByProfile(con, profileId));

        }
        DBUtils.closeRs(rs);
        DBUtils.closeStmt(stmt);

    } catch (Exception e) {
        log.error(e.toString(), e);
    }

    return profile;
}

From source file:gdt.jgui.base.JBasesPanel.java

static void refreshListProcedure(JMainConsole console, String entihome$) {
    try {//from   w  w w  .  j  av  a 2s  .c  o m
        InputStream is = JProcedurePanel.class.getResourceAsStream("list.tar");
        TarArchiveInputStream tis = new TarArchiveInputStream(is);
        ArchiveHandler.extractEntitiesFromTar(entihome$, tis);
        Entigrator entigrator = console.getEntigrator(entihome$);
        Sack procedure = entigrator.getEntityAtKey(JProcedurePanel.PROCEDURE_LIST_KEY);
        String procedureLocator$ = EntityHandler.getEntityLocator(entigrator, procedure);
        JEntityPrimaryMenu.reindexEntity(console, procedureLocator$);
    } catch (Exception e) {
        Logger.getLogger(JQueryPanel.class.getName()).severe(e.toString());
    }
}

From source file:gdt.jgui.base.JBasesPanel.java

static void refreshAllEntitiesQuery(JMainConsole console, String entihome$) {
    try {/*from   ww w  .  j  a  va  2s.  c o  m*/
        InputStream is = JQueryPanel.class.getResourceAsStream("query.tar");
        TarArchiveInputStream tis = new TarArchiveInputStream(is);
        ArchiveHandler.extractEntitiesFromTar(entihome$, tis);
        Entigrator entigrator = console.getEntigrator(entihome$);
        Sack query = entigrator.getEntityAtKey(JQueryPanel.QUERY_ALL_ENTITIES_KEY);
        String queryLocator$ = EntityHandler.getEntityLocator(entigrator, query);
        JEntityPrimaryMenu.reindexEntity(console, queryLocator$);
    } catch (Exception e) {
        Logger.getLogger(JQueryPanel.class.getName()).severe(e.toString());
    }
}

From source file:edu.usc.polar.CompositeNERAgreementParser.java

public static void dir(String path, String[] args) {
    try {//  w  w w.  j  a  v a 2s.c o  m

        File root = new File(path);
        if (root.isFile()) {

            if (counter >= 1000 || file == null) {
                counter = 0;
                jsonCount++;
                file = new File(
                        "C:\\Users\\Snehal\\Documents\\tikaSimilarityTestSet\\CompositeNER\\CompositeNER_"
                                + jsonCount + ".json");
                if (jsonFile != null) {
                    jsonFile.write("{\"CompositeNER\":");
                    jsonFile.write(jsonArray.toJSONString());
                    jsonFile.write("}");
                    //System.out.println(jsonArray.toJSONString());
                    jsonFile.close();
                }
                jsonFile = new FileWriter(file);
                jsonArray = new JSONArray();
            }

            if (!root.getName().equals((".DS_Store"))) {
                CompositeNER(root.getAbsolutePath(), args);
                counter++;
            }
        } else {
            File[] list = root.listFiles();
            if (list == null) {
                return;
            }
            for (File f : list) {
                if (f.isDirectory()) {
                    dir(f.getAbsolutePath(), args);
                    System.out.println("Dir:" + f.getAbsoluteFile());
                } else {
                    if (counter >= 1000 || file == null) {
                        counter = 0;
                        jsonCount++;
                        file = new File(
                                "C:\\Users\\Snehal\\Documents\\tikaSimilarityTestSet\\CompositeNER\\CompositeNER_"
                                        + jsonCount + ".json");
                        // System.out.print("check"+jsonArray.toJSONString());
                        if (jsonFile != null) {
                            jsonFile.write("{\"CompositeNER\":");
                            jsonFile.write(jsonArray.toJSONString());
                            jsonFile.write("}");
                            //System.out.println(jsonArray.toJSONString());
                            jsonFile.close();
                        }
                        jsonFile = new FileWriter(file);
                        jsonArray = new JSONArray();
                    }

                    if (!f.getName().equals((".DS_Store"))) {
                        CompositeNER(f.getAbsolutePath(), args);
                        counter++;
                        // add json   
                    }
                }
            }
        }
    } catch (Exception e) {
        e.toString();

    }
}

From source file:com.snaker.ssl.EasySSLProtocolSocketFactory.java

private static SSLContext createEasySSLContext() {
    try {/*from   w w w.j  av a2 s. co  m*/
        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) {
        LOG.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}

From source file:com.keybox.manage.db.ProfileDB.java

/**
 * returns all profile information/*w w w  .jav  a2  s  .  c o m*/
 *
 * @return list of profiles
 */
public static List<Profile> getAllProfiles() {

    ArrayList<Profile> profileList = new ArrayList<>();
    Connection con = null;
    try {
        con = DBUtils.getConn();
        PreparedStatement stmt = con.prepareStatement("select * from  profiles order by nm asc");
        ResultSet rs = stmt.executeQuery();

        while (rs.next()) {
            Profile profile = new Profile();
            profile.setId(rs.getLong("id"));
            profile.setNm(rs.getString("nm"));
            profile.setDesc(rs.getString("desc"));
            profileList.add(profile);

        }
        DBUtils.closeRs(rs);
        DBUtils.closeStmt(stmt);

    } catch (Exception e) {
        log.error(e.toString(), e);
    } finally {
        DBUtils.closeConn(con);
    }

    return profileList;
}

From source file:com.ts.db.connector.ConnectorDriverManager.java

private static Driver getDriver(File jar, String url, ClassLoader cl) throws IOException {
    ZipFile zipFile = new ZipFile(jar);
    try {/*from w  ww  . jav a2s  .  c  o  m*/
        for (ZipEntry entry : Iteration.asIterable(zipFile.entries())) {
            final String name = entry.getName();
            if (name.endsWith(".class")) {
                final String fqcn = name.replaceFirst("\\.class", "").replace('/', '.');
                try {
                    Class<?> c = DynamicLoader.loadClass(fqcn, cl);
                    if (Driver.class.isAssignableFrom(c)) {
                        Driver driver = (Driver) c.newInstance();
                        if (driver.acceptsURL(url)) {
                            return driver;
                        }
                    }
                } catch (Exception ex) {
                    if (log.isTraceEnabled()) {
                        log.trace(ex.toString());
                    }
                }
            }
        }
    } finally {
        zipFile.close();
    }
    return null;
}

From source file:com.dwdesign.tweetings.util.WebViewProxySettings.java

public static boolean setProxy(WebView webView, String host, int port) {
    final Context context = webView.getContext();
    // PSIPHON: added support for Android 4.x WebView proxy
    try {/*from   w ww. j ava  2 s .c om*/
        final Class<?> webViewCoreClass = Class.forName("android.webkit.WebViewCore");
        final Class<?> proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
        if (webViewCoreClass != null && proxyPropertiesClass != null) {
            final Method m = webViewCoreClass.getDeclaredMethod("sendStaticMessage", Integer.TYPE,
                    Object.class);
            final Constructor<?> c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE,
                    String.class);

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

                // android.webkit.WebViewCore.EventHub.PROXY_CHANGED = 193;
                m.invoke(null, 193, properties);
                return true;
            }
        }
    } catch (final Exception e) {
        Log.e("ProxySettings",
                "Exception setting WebKit proxy through android.net.ProxyProperties: " + e.toString());
    }

    try {
        final Object requestQueueObject = getRequestQueue(context);
        if (requestQueueObject != null) {
            // Create Proxy config object and set it into request Q
            final HttpHost httpHost = new HttpHost(host, port, "http");
            setDeclaredField(requestQueueObject, "mProxyHost", httpHost);
            // Log.d("Webkit Setted Proxy to: " + host + ":" + port);
            return true;
        }
    } catch (final Exception e) {
        Log.e("ProxySettings",
                "Exception setting WebKit proxy through android.webkit.Network: " + e.toString());
    }

    return false;
}

From source file:com.nubits.nubot.utils.VersionInfo.java

private static HashMap getInfoFile() {
    String wdir = System.getProperty("user.dir");

    String fp = wdir + "/" + Settings.INFO_FILE;
    File file = new File(fp);
    try {// w w w.  j  a v  a 2s  .  c o m
        List lines = FileUtils.readLines(file, "UTF-8");
        HashMap km = new HashMap();
        for (Object o : lines) {
            String l = "" + o;
            try {
                String[] a = l.split("=");
                km.put(a[0], a[1]);
            } catch (Exception e) {
                //ignore line with "="
            }

        }
        return km;
    } catch (Exception e) {
        //throw e;
        LOG.error(e.toString());
    }
    return null;
}