List of usage examples for java.io UnsupportedEncodingException printStackTrace
public void printStackTrace()
From source file:org.wso2.mdm.qsg.utils.HTTPInvoker.java
public static HTTPResponse sendHTTPPutWithOAuthSecurity(String url, String payload, HashMap<String, String> headers) { HttpPut put = null;/*from w ww . j a v a 2 s .co m*/ HttpResponse response = null; HTTPResponse httpResponse = new HTTPResponse(); CloseableHttpClient httpclient = null; try { httpclient = (CloseableHttpClient) createHttpClient(); StringEntity requestEntity = new StringEntity(payload, Constants.UTF_8); put = new HttpPut(url); put.setEntity(requestEntity); for (String key : headers.keySet()) { put.setHeader(key, headers.get(key)); } put.setHeader(Constants.Header.AUTH, OAUTH_BEARER + oAuthToken); response = httpclient.execute(put); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyStoreException e) { e.printStackTrace(); } catch (KeyManagementException e) { e.printStackTrace(); } BufferedReader rd = null; try { rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); } catch (IOException e) { e.printStackTrace(); } StringBuffer result = new StringBuffer(); String line = ""; try { while ((line = rd.readLine()) != null) { result.append(line); } } catch (IOException e) { e.printStackTrace(); } httpResponse.setResponseCode(response.getStatusLine().getStatusCode()); httpResponse.setResponse(result.toString()); try { httpclient.close(); } catch (IOException e) { e.printStackTrace(); } return httpResponse; }
From source file:org.wso2.mdm.qsg.utils.HTTPInvoker.java
public static HTTPResponse sendHTTPPostWithOAuthSecurity(String url, String payload, HashMap<String, String> headers) { HttpPost post = null;/*from w w w. j av a 2 s . c o m*/ HttpResponse response = null; HTTPResponse httpResponse = new HTTPResponse(); CloseableHttpClient httpclient = null; try { httpclient = (CloseableHttpClient) createHttpClient(); StringEntity requestEntity = new StringEntity(payload, Constants.UTF_8); post = new HttpPost(url); post.setEntity(requestEntity); for (String key : headers.keySet()) { post.setHeader(key, headers.get(key)); } post.setHeader(Constants.Header.AUTH, OAUTH_BEARER + oAuthToken); response = httpclient.execute(post); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyStoreException e) { e.printStackTrace(); } catch (KeyManagementException e) { e.printStackTrace(); } BufferedReader rd = null; try { rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); } catch (IOException e) { e.printStackTrace(); } StringBuffer result = new StringBuffer(); String line = ""; try { while ((line = rd.readLine()) != null) { result.append(line); } } catch (IOException e) { e.printStackTrace(); } httpResponse.setResponseCode(response.getStatusLine().getStatusCode()); httpResponse.setResponse(result.toString()); try { httpclient.close(); } catch (IOException e) { e.printStackTrace(); } return httpResponse; }
From source file:org.wso2.mdm.qsg.utils.HTTPInvoker.java
public static HTTPResponse uploadFile(String url, String fileName, String fileContentType) { HttpPost post = null;/*from www .j a v a 2s . c o m*/ HttpResponse response = null; HTTPResponse httpResponse = new HTTPResponse(); CloseableHttpClient httpclient = null; try { httpclient = (CloseableHttpClient) createHttpClient(); post = new HttpPost(url); File file = new File(fileName); MultipartEntity mpEntity = new MultipartEntity(); ContentBody cbFile = new FileBody(file, fileContentType); mpEntity.addPart("file", cbFile); post.setEntity(mpEntity); post.setHeader(Constants.Header.AUTH, OAUTH_BEARER + oAuthToken); //post.setHeader(Constants.Header.CONTENT_TYPE, "multipart/form-data"); post.setHeader("Accept", Constants.ContentType.APPLICATION_JSON); response = httpclient.execute(post); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyStoreException e) { e.printStackTrace(); } catch (KeyManagementException e) { e.printStackTrace(); } BufferedReader rd = null; try { rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); } catch (IOException e) { e.printStackTrace(); } StringBuffer result = new StringBuffer(); String line = ""; try { while ((line = rd.readLine()) != null) { result.append(line); } } catch (IOException e) { e.printStackTrace(); } httpResponse.setResponseCode(response.getStatusLine().getStatusCode()); httpResponse.setResponse(result.toString()); try { httpclient.close(); } catch (IOException e) { e.printStackTrace(); } return httpResponse; }
From source file:com.alibaba.rocketmq.common.MixAll.java
/** * ?Properties Properties??// ww w . j a v a 2 s . c o m */ public static Properties string2Properties(final String str) { Properties properties = new Properties(); try { InputStream in = new ByteArrayInputStream(str.getBytes(DEFAULT_CHARSET)); properties.load(in); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } return properties; }
From source file:com.atinternet.tracker.Tool.java
/** * Decoding a string//from w w w . ja v a2s. c o m * * @param s String * @return String */ static String percentDecode(String s) { try { s = URLDecoder.decode(s, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return s; }
From source file:com.aqnote.shared.cryptology.digest.SHA.java
public final static String sha1(String src) { if (isBlank(src)) return ""; try {/*w w w .ja va 2 s .c om*/ return sha1(src.getBytes(DEFAULT_CHARSET)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return ""; }
From source file:com.aqnote.shared.cryptology.digest.SHA.java
public final static String sha224(String src) { if (isBlank(src)) return ""; try {/*from w w w . j a v a 2s .c o m*/ return sha224(src.getBytes(DEFAULT_CHARSET)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return ""; }
From source file:com.aqnote.shared.cryptology.digest.SHA.java
public final static String sha256(String src) { if (isBlank(src)) return ""; try {//from w w w . j a v a 2s . c o m return sha256(src.getBytes(DEFAULT_CHARSET)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return ""; }
From source file:com.aqnote.shared.cryptology.digest.SHA.java
public final static String sha384(String src) { if (isBlank(src)) return ""; try {/*from w w w . j a va2 s . c om*/ return sha384(src.getBytes(DEFAULT_CHARSET)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return ""; }
From source file:com.aqnote.shared.cryptology.digest.SHA.java
public final static String sha512(String src) { if (isBlank(src)) return ""; try {/*from w w w. java 2s . c o m*/ return sha512(src.getBytes(DEFAULT_CHARSET)); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return ""; }