List of usage examples for java.io UnsupportedEncodingException printStackTrace
public void printStackTrace()
From source file:Main.java
static public String getNodeValue(Element parent, String nodeName) { NodeList nodes = parent.getElementsByTagName(nodeName); if (nodes.getLength() == 0) return null; Element curElem = (Element) nodes.item(0); Node textNode = curElem.getFirstChild(); if (textNode != null) { String encVal = curElem.getAttribute("enc"); String charSetVal = curElem.getAttribute("charSet"); String returnVal = textNode.getNodeValue(); if (encVal != null && encVal.equals("t")) { if (charSetVal == null) return (URLDecoder.decode(returnVal)); else// ww w. java2s .c o m try { return (URLDecoder.decode(returnVal, charSetVal)); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return (returnVal); } else return (""); }
From source file:net.ccghe.utils.Server.java
public static void UploadFile(String path, FileTransmitter transmitter) { MultipartEntity entity = new MultipartEntity(); try {//from w ww. jav a 2 s. c om entity.addPart("usr", new StringBody(user)); entity.addPart("pwd", new StringBody(password)); entity.addPart("cmd", new StringBody(CMD_UPLOAD_FILE)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } new UploadOneFile(path, serverURL, transmitter, entity); }
From source file:com.puzzle.module.send.sign.SignXml.java
public static String getKeyName() { try {// w w w.j a va 2 s .c o m String idNumber = ClientApi.getSingletonClientApi().getCardID2(); return idNumber; } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } return null; }
From source file:Tools.HttpClientUtil.java
public static String postRequest(List<NameValuePair> paramsList) { HttpClient client = new DefaultHttpClient(); HttpPost post = null;/*from www. ja v a 2 s. co m*/ String requestedServlet = ServletRequest.getServletRequest(); StringBuilder sb = new StringBuilder(); if (requestedServlet.equals(Constant.LOGIN_SERVLET)) { try { post = new HttpPost(Constant.SERVER_URL + Constant.LOGIN_SERVLET); post.setEntity(new UrlEncodedFormEntity(paramsList)); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } } else if (requestedServlet.equals(Constant.BILLING_SERVLET)) { post = new HttpPost(Constant.SERVER_URL + Constant.BILLING_SERVLET); try { post.setEntity(new UrlEncodedFormEntity(paramsList)); } catch (UnsupportedEncodingException ex) { Logger.getLogger(HttpClientUtil.class.getName()).log(Level.SEVERE, null, ex); } } else if (requestedServlet.equals(Constant.FOOD_LIST_SERVLET)) { post = new HttpPost(Constant.SERVER_URL + Constant.FOOD_LIST_SERVLET); try { post.setEntity(new UrlEncodedFormEntity(paramsList)); } catch (UnsupportedEncodingException ex) { Logger.getLogger(HttpClientUtil.class.getName()).log(Level.SEVERE, null, ex); } } else { post = new HttpPost(Constant.SERVER_URL + Constant.EMPLOYEE_SERVLET); try { post.setEntity(new UrlEncodedFormEntity(paramsList)); } catch (UnsupportedEncodingException ex) { Logger.getLogger(HttpClientUtil.class.getName()).log(Level.SEVERE, null, ex); } } try { HttpResponse response = client.execute(post); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String line = ""; while ((line = rd.readLine()) != null) { System.out.println(line); sb.append(line); } } catch (IOException e) { e.printStackTrace(); } //} return sb.toString(); }
From source file:com.github.dactiv.common.utils.EncodeUtils.java
/** * URL ?, EncodeUTF-8. /* www .j a v a2 s .c o m*/ */ public static String urlEncode(String part) { try { return URLEncoder.encode(part, DEFAULT_URL_ENCODING); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return part; }
From source file:eu.eexcess.partnerdata.evaluation.enrichment.PartnerRecommenderEvaluationTestHelper.java
static public StringEntity createParamsForPartnerRecommender(int records, ArrayList<String> keywords) { StringEntity params = null;//from w ww.ja v a 2 s. c o m try { String userprofile = "<eexcess-secure-user-profile numResults=\"" + records + "\" firstName=\"Hugo\" lastName=\"Boss\" birthDate=\"2013-10-14T05:06:44.550+02:00\"> <contextKeywords> "; for (int i = 0; i < keywords.size(); i++) { userprofile += "<contextKeywords><text>" + keywords.get(i) + "</text></contextKeywords>"; } userprofile += " </contextKeywords></eexcess-secure-user-profile>"; params = new StringEntity(userprofile); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return params; }
From source file:com.github.dactiv.common.utils.EncodeUtils.java
/** * URL ?, EncodeUTF-8. //w ww .j a va2 s .c o m */ public static String urlDecode(String part) { try { return URLDecoder.decode(part, DEFAULT_URL_ENCODING); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return part; }
From source file:de.pawlidi.openaletheia.Aletheia.java
/** * //www. j a va2s .c o m * @param rootDirectory * @param password * @return */ static String encryptPassword(final String rootDirectory, String password) { if (StringUtils.isNotEmpty(rootDirectory) && StringUtils.isNotEmpty(password)) { final String privateKeyString = KeyGenerator.readPrivateKeyFile(rootDirectory); if (StringUtils.isNotEmpty(privateKeyString)) { RSAPrivateKey privateKey = CipherUtils.buildPrivateKey(privateKeyString); byte[] encryptedData = CipherUtils.encrypt(Converter.getBytesUtf8(password), privateKey); try { password = new String(encryptedData, Converter.UTF_8); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } return password; }
From source file:de.pawlidi.openaletheia.Aletheia.java
/** * /*from www . ja v a 2 s . c om*/ * @param rootDirectory * @param password * @return */ static String decryptPassword(final String rootDirectory, String password) { if (StringUtils.isNotEmpty(rootDirectory) && StringUtils.isNotEmpty(password)) { final String publicKeyString = KeyGenerator.readPublicKeyFile(rootDirectory); if (StringUtils.isNotEmpty(publicKeyString)) { RSAPublicKey publicKey = CipherUtils.buildPublicKey(publicKeyString); byte[] decryptedData = CipherUtils.decrypt(Converter.getBytesUtf8(password), publicKey); try { password = new String(decryptedData, Converter.UTF_8); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } return password; }
From source file:com.ncu.sdroidagent.ServerUtilities.java
/** * Issue a POST request to the SDroid server. * * @param endpoint// w w w .j a v a 2 s .c o m * POST address. * @param params * request parameters. * * @throws IOException * propagated from POST. */ private static void post(String endpoint, Map<String, String> params) throws IOException { String result = null; HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(endpoint); List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(); Iterator<Entry<String, String>> iterator = params.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, String> param = iterator.next(); nameValuePair.add(new BasicNameValuePair(param.getKey(), param.getValue())); } try { httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair, HTTP.UTF_8)); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } try { HttpResponse response = httpClient.execute(httpPost); if (response.getStatusLine().getStatusCode() == 200) { result = EntityUtils.toString(response.getEntity()); } else { result = "HttpPost False!"; } Log.d("ServerUtilities", "result: " + result); } catch (ClientProtocolException cpe) { cpe.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } }