Example usage for java.io UnsupportedEncodingException printStackTrace

List of usage examples for java.io UnsupportedEncodingException printStackTrace

Introduction

In this page you can find the example usage for java.io UnsupportedEncodingException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:net.antidot.semantic.rdf.rdb2rdf.dm.core.DirectMapper.java

private static void convertNextTuple(SesameDataSet result, TupleExtractor te, DirectMappingEngine dme,
        DriverType driver, String baseURI) throws UnsupportedEncodingException {
    Tuple tuple = te.getCurrentTuple();/*from w w  w. java  2s.c om*/
    //Tuple tuple = null;
    log.debug("[DirectMapper:convertNextTuple] Tuple extracted : " + tuple);
    try {
        // Extract referenced rows
        HashMap<Key, Tuple> referencedTuples = te.getReferencedTuples(driver, tuple);
        // Extract primary-is-foreign Key 
        Key primaryIsForeignKey = te.getCurrentPrimaryIsForeignKey(referencedTuples.keySet(), tuple);
        log.debug("[DirectMapper:convertNextTuple] Number of referenced tuples generated : "
                + referencedTuples.values().size());

        HashSet<Statement> statements = dme.extractTriplesFrom(tuple, referencedTuples, primaryIsForeignKey,
                baseURI);
        for (Statement triple : statements) {
            log.debug("[DirectMapper:convertNextTuple] Triple generated : " + triple);
            result.add(triple.getSubject(), triple.getPredicate(), triple.getObject());
            nbTriples++;
        }
        if (nbTriples / 50000 > lastModulo) {
            log.info(nbTriples + " triples has already been extracted.");
            lastModulo = nbTriples / 50000;
        }
    } catch (UnsupportedEncodingException e) {
        log.error("[DirectMapper:generateDirectMapping] Encoding not supported.");
        e.printStackTrace();
    }
}

From source file:com.arthackday.killerapp.util.Util.java

public static String makeJsonRpcCall(String jsonRpcUrl, JSONObject payload, String authToken) {
    Log.d(LOG_TAG, jsonRpcUrl + " " + payload.toString());
    try {//from   w  w w  .ja v  a2 s . c  om
        HttpClient client = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(jsonRpcUrl);

        if (authToken != null) {
            httpPost.addHeader(new BasicHeader("Authorization", "GoogleLogin auth=" + authToken));
        }

        httpPost.setEntity(new StringEntity(payload.toString(), "UTF-8"));

        HttpResponse httpResponse = client.execute(httpPost);
        if (200 == httpResponse.getStatusLine().getStatusCode()) {
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(httpResponse.getEntity().getContent(), "UTF-8"), 8 * 1024);

            StringBuilder sb = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                sb.append(line).append("\n");
            }

            return sb.toString();
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.ax.utils.CookieUtils.java

/**
 * ?cookie<code>name</code> type??utf-8?
 * /* w ww. j  a v a2 s  . com*/
 * @param request
 *            the servlet request.
 * @param name
 *            the name of the cookie.
 * @return the value if it exists, otherwise <tt>null</tt>.
 */
public static String getCookieValue(HttpServletRequest request, String name, int type) {

    try {
        String value = CookieUtils.getCookieValue(request, name);
        if (type == 1) {
            return value;
        } else {// type=2
            return URLDecoder.decode(value, "UTF-8");
        }
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return null;
    }

}

From source file:fr.eo.util.dumper.Dumper.java

private static String getCompressedString(String value) {

    byte[] output = new byte[8096];

    try {/*w  w w.  j  a va  2 s . c o m*/
        byte[] input = value.getBytes("UTF-8");
        Deflater compresser = new Deflater(Deflater.BEST_COMPRESSION, true);
        compresser.setInput(input);
        compresser.finish();
        int compressedDataLength = compresser.deflate(output);
        return "X'" + Hex.encodeHexString(Arrays.copyOf(output, compressedDataLength)) + "'";
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    return null;
}

From source file:com.brobwind.brodm.NetworkUtils.java

public static void runCommand(HttpClient client, String token, String url, String cmd, OnMessage callback) {
    HttpPost request = new HttpPost(url);
    request.addHeader("Authorization", "Basic " + token);
    request.addHeader("Content-Type", "application/json");

    try {//from www  .  j a  va2  s . com
        StringEntity content = new StringEntity(cmd);
        request.setEntity(content);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        callback.onMessage(null, e.getMessage());
        return;
    }

    try {
        HttpResponse response = client.execute(request);
        if (response.getStatusLine().getStatusCode() != HttpURLConnection.HTTP_OK) {
            Log.v(TAG, " -> ABORT: " + response.getStatusLine());
            request.abort();
            callback.onMessage(null, "ABORT: " + response.getStatusLine());
            return;
        }
        String result = EntityUtils.toString(response.getEntity());
        Log.v(TAG, " -> RESULT: " + result);
        callback.onMessage(result, null);
        return;
    } catch (Exception e) {
        e.printStackTrace();
        callback.onMessage(null, e.getMessage());
    }
}

From source file:com.piusvelte.hydra.HydraRequest.java

public static HydraRequest fromGet(HttpServletRequest request) throws Exception {
    HydraRequest hydraRequest;//from   w  ww  .  ja va 2s. co m
    try {
        hydraRequest = new HydraRequest(request);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        throw new Exception("bad parameter encoding");
    }
    hydraRequest.action = ACTION_QUERY;
    return hydraRequest;
}

From source file:com.piusvelte.hydra.HydraRequest.java

public static HydraRequest fromPut(HttpServletRequest request) throws Exception {
    HydraRequest hydraRequest;//w  w  w . ja va  2 s. com
    try {
        hydraRequest = new HydraRequest(request);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        throw new Exception("bad parameter encoding");
    }
    if (!hydraRequest.hasDatabase() || !hydraRequest.hasTarget())
        throw new Exception("invalid request");
    hydraRequest.action = ACTION_UPDATE;
    return hydraRequest;
}

From source file:com.piusvelte.hydra.HydraRequest.java

public static HydraRequest fromDelete(HttpServletRequest request) throws Exception {
    HydraRequest hydraRequest;//from  ww  w . ja v a  2s .c  o m
    try {
        hydraRequest = new HydraRequest(request);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        throw new Exception("bad parameter encoding");
    }
    if (!hydraRequest.hasDatabase() || !hydraRequest.hasTarget())
        throw new Exception("invalid request");
    hydraRequest.action = ACTION_DELETE;
    return hydraRequest;
}

From source file:messenger.YahooFinanceAPI.java

public static String httppost(String url, List<NameValuePair> header, String refer, boolean cookie) {
    DefaultHttpClient httpclient = new DefaultHttpClient();
    if (cookie)/*  w w w .j a  v  a  2s  .  c  o m*/
        httpclient.setCookieStore(cookiestore);
    else if (cookiestore1 != null)
        httpclient.setCookieStore(cookiestore1);
    if (use_proxy) {
        HttpHost proxy = new HttpHost(PROXY_NAME, PROXY_PORT);
        httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
    }

    HttpPost httpPost = new HttpPost(url);
    httpPost.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);

    Header[] headers = { new BasicHeader("Accept",
            "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"),
            new BasicHeader("Content-Type", "application/x-www-form-urlencoded"),
            new BasicHeader("Origin", "http://aomp.judicial.gov.tw"), new BasicHeader("Referer", refer),
            new BasicHeader("User-Agent",
                    "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.55 Safari/534.3") };

    httpPost.setHeaders(headers);

    try {
        httpPost.setEntity(new UrlEncodedFormEntity(header, "Big5"));
    } catch (UnsupportedEncodingException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    HttpResponse response = null;
    String responseString = null;
    try {
        response = httpclient.execute(httpPost);
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            if (cookie)
                cookiestore = httpclient.getCookieStore();
            else
                cookiestore1 = httpclient.getCookieStore();
            responseString = EntityUtils.toString(response.getEntity());
            // pG^O 200 OK ~X
            // System.out.println(responseString);
            //
        } else if (response.getStatusLine().getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) {
            Header[] urlh = response.getAllHeaders();
            System.out.println(urlh.toString());
        } else {
            System.out.println(response.getStatusLine());
        }

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    httpclient.getConnectionManager().shutdown();
    return responseString;
}

From source file:jp.co.conit.sss.sp.ex1.util.SSSApiUtil.java

/**
 * ????/*w w w .  j a v  a 2 s . co m*/
 * 
 * @return
 */
private static String getToken(Context context) {
    String token = null;
    try {
        token = URLEncoder.encode(Util.getToken(Util.getSignature(context)), "UTF8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return token;
}