List of usage examples for java.io UnsupportedEncodingException printStackTrace
public void printStackTrace()
From source file:com.bconomy.autobit.Encryption.java
public static String encrypt(String cleartext) { if (cleartext == null || cleartext.equals("")) return ""; try {/*from ww w. j ava 2 s .c om*/ return Base64.encodeBase64String(encrypt(cleartext.getBytes("UTF-8"))); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } return ""; }
From source file:com.bconomy.autobit.Encryption.java
public static String decrypt(String cyphertext) { if (cyphertext == null || cyphertext.equals("") || !Base64.isBase64(cyphertext)) return ""; try {/* ww w . ja v a 2 s . c o m*/ return new String(decrypt(Base64.decodeBase64(cyphertext)), "UTF-8"); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } return ""; }
From source file:th.ac.kmutt.chart.rest.application.Main.java
private static void systemConfig(SystemM param) { SystemM sys = param;/*from ww w .ja v a 2s . c o m*/ String url = "system"; HttpPost httppost = new HttpPost("http://localhost:8081/ChartServices/rest/" + url); XStream xstream = new XStream(new Dom4JDriver()); Class c = null; try { c = Class.forName(sys.getClass().getName()); } catch (ClassNotFoundException e2) { e2.printStackTrace(); } xstream.processAnnotations(c); ByteArrayEntity entity = null; String xString = xstream.toXML(sys); try { entity = new ByteArrayEntity(xString.getBytes("UTF-8")); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } httppost.setEntity(entity); CloseableHttpClient httpclient = HttpClientBuilder.create().build(); HttpResponse response = null; HttpEntity resEntity = null; try { response = httpclient.execute(httppost); resEntity = response.getEntity(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } //httpclient.getConnectionManager().shutdown(); try { httpclient.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.saltedge.sdk.network.SERestClient.java
public static boolean post(String servicePath, String jsonRequest, SEHTTPResponseHandler responseHandler, HashMap<String, String> headers) { if (isNetworkUnavailable() || responseHandler == null) { return false; }//from ww w .jav a2 s . c o m AsyncHttpClient client = createHttpClient(headers); RequestHandle handler = null; try { handler = client.post(SaltEdgeSDK.getInstance().getContext(), getAbsoluteUrl(servicePath), new StringEntity(jsonRequest, HTTP.UTF_8), SEConstants.MIME_TYPE_JSON, responseHandler); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return (handler != null); }
From source file:com.lib.pygmy.util.TurnData.java
public static TurnData unpersist(byte[] byteArray) { if (byteArray == null) { Log.d(TAG, "Empty array - possible bug."); return new TurnData(); }/*from www.j a va 2 s.c o m*/ String st = null; try { st = new String(byteArray, "UTF-16"); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); return null; } TurnData retVal = new TurnData(); try { JSONObject obj = new JSONObject(st); if (obj.has("state")) { retVal.state = obj.getString("state"); } if (obj.has("turnCounter")) { retVal.turnCounter = obj.getInt("turnCounter"); } if (obj.has("game")) { retVal.game = obj.getString("game"); } if (obj.has("version")) { retVal.version = obj.getString("version"); } } catch (JSONException e) { e.printStackTrace(); } return retVal; }
From source file:com.net.wx.util.Encodes.java
/** * URL ?, EncodeUTF-8./*from ww w .ja v a 2 s. com*/ */ public static String urlEncode(String part) { try { return URLEncoder.encode(part, DEFAULT_URL_ENCODING); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return null; } }
From source file:com.cssweb.android.connect.ConnPool.java
public static JSONObject sendReq(String funcname, String funcno, String reqbuf) throws JSONException { StringBuffer sb = new StringBuffer(); sb.append(TradeUtil.getGlobalRequest(funcname, funcno)); sb.append(reqbuf);//from www .ja v a2 s .c om sb.append("&ram=" + Math.random()); String sbStr = sb.toString(); if ("190101".equals(funcno) || "203113".equals(funcno) || "203111".equals(funcno) || "203526".equals(funcno) || "203119".equals(funcno) || "202010".equals(funcno) || "202012".equals(funcno)) { sbStr = sbStr.replace("isSafe=0", "isSafe=1"); } Log.i("==", sbStr); String req = ""; try { req = new String(Base64.encode(sbStr.getBytes("gb2312"))); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } req = TradeUtil.getResult(req); Log.i(">>>>>url>>>>>>>", getURL() + req); return Conn.tradeReq(getURL() + req); }
From source file:com.net.wx.util.Encodes.java
/** * URL ?, EncodeUTF-8.//from w w w.j a v a 2 s . c o m */ public static String urlDecode(String part) { try { return URLDecoder.decode(part, DEFAULT_URL_ENCODING); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return null; } }
From source file:com.alta189.cyborg.commandkit.util.HttpUtil.java
public static String hastebin(String data) { HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost(hastebin); try {/*from w w w . j a v a 2 s . co m*/ post.setEntity(new StringEntity(data)); HttpResponse response = client.execute(post); String result = EntityUtils.toString(response.getEntity()); return "http://hastebin.com/" + new Gson().fromJson(result, Hastebin.class).getKey(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:niclients.main.regni.java
static boolean createpub() throws UnsupportedEncodingException { post = new HttpPost(fqdn + "/.well-known/netinfproto/publish"); // -l int i = 0;// w w w. ja v a2s . c om StringBody url = new StringBody(niname); // -n reqEntity.addPart("URI", url); StringBody msgid = new StringBody(Integer.toString(randomGenerator.nextInt(100000000))); // generate reqEntity.addPart("msgid", msgid); for (i = 0; i < loc.size(); i++) { try { StringBody l = new StringBody(loc.get(i)); reqEntity.addPart("loc" + i, l); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } post.setEntity(reqEntity); return true; }