List of usage examples for java.io UnsupportedEncodingException printStackTrace
public void printStackTrace()
From source file:com.iterzp.momo.filter.EncodingConvertFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { if (request.getMethod().equalsIgnoreCase("GET")) { for (Iterator<String[]> iterator = request.getParameterMap().values().iterator(); iterator.hasNext();) { String[] parames = iterator.next(); for (int i = 0; i < parames.length; i++) { try { parames[i] = new String(parames[i].getBytes(fromEncoding), toEncoding); } catch (UnsupportedEncodingException e) { e.printStackTrace(); }//from w ww. j av a 2s .c o m } } } filterChain.doFilter(request, response); }
From source file:com.procleus.brime.utils.JSONParser.java
public JSONObject getJSONFromUrl(String url) { try {// ww w . j a v a 2 s . c om DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } 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(); json = sb.toString(); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); } return jObj; }
From source file:com.saltedge.sdk.network.SEHTTPResponseHandler.java
@Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { super.onSuccess(statusCode, headers, responseBody); if (responseBody == null || responseBody.length == 0) { return;/* w w w . j ava2 s. c om*/ } try { String resultString = new String(responseBody, "UTF-8"); if (resultString.startsWith("{")) { return; } JSONObject resultJson = new JSONObject(); resultJson.put(SEConstants.KEY_DATA, resultString); onSuccess(statusCode, headers, resultJson); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } }
From source file:net.sourceforge.jwbf.actions.mw.util.GetEnvironmentVars.java
/** * /*from w w w .j av a2s . c om*/ * @param name of article * @param tab ref on a tabel with inner values * @param login a */ public GetEnvironmentVars(final String name, Hashtable<String, String> tab, LoginData login) { String uS = ""; this.tab = tab; try { uS = "/index.php?title=" + URLEncoder.encode(name, MediaWikiBot.CHARSET) + "&action=edit&dontcountme=s"; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } msgs.add(new GetMethod(uS)); }
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.db.ws.ActivityWSPostAsyncTask.java
private int executeCheckIn(ActivityDO a) { String json = new GsonBuilder().create().toJson(a, ActivityDO.class); String uri = Session.getSingleInstance().getWSPath() + "/_ah/api/activityendpoint/v1/activity"; try {//from ww w. j a v a 2s.c om HttpPost httpPost = new HttpPost(uri); httpPost.setEntity(new StringEntity(json)); httpPost.setHeader("Accept", "application/json"); httpPost.setHeader("Content-type", "application/json"); new DefaultHttpClient().execute(httpPost); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return WSConstants.POST_RESPONSE_KO; } catch (ClientProtocolException e) { e.printStackTrace(); return WSConstants.POST_RESPONSE_KO; } catch (IOException e) { e.printStackTrace(); return WSConstants.POST_RESPONSE_KO; } return WSConstants.POST_RESPONSE_OK; }
From source file:com.streaming.sweetplayer.utils.JSONParser.java
public JSONObject getJSONFromUrl(String url) { // Making HTTP request try {/* w w w. ja v a 2 s . c o m*/ // DefaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8); StringBuilder sb = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { sb.append(line).append("\n"); } is.close(); json = sb.toString(); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } // try parse the string to a JSON object try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); } // return JSON String return jObj; }
From source file:com.enonic.cms.domain.localization.LocalizationResourceBundle.java
private String createUTF8EncodedPhrase(String localizedPhrase) { if (StringUtils.isBlank(localizedPhrase)) { return null; }//from ww w . j av a2 s .c o m try { return new String(localizedPhrase.getBytes(LATIN_1_ENCODING), UTF_8_ENCODING); } catch (UnsupportedEncodingException e) { // Woha, this should not happen! e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. return null; } }