List of usage examples for java.io UnsupportedEncodingException toString
public String toString()
From source file:org.apache.felix.webconsole.plugins.upnp.internal.Base64.java
static String newStringUtf8(byte[] bytes) { if (bytes == null) { return null; }// w w w . j a va 2s. c o m try { return new String(bytes, "UTF-8"); //$NON-NLS-1$ } catch (UnsupportedEncodingException e) { // cannot use 'new Exception(message, throwable)' because it's not supported by pre-java5 throw new IllegalStateException(e.toString()); } }
From source file:org.wso2.mdm.agent.services.MessageProcessor.java
/** * Call the message retrieval end point of the server to get messages pending. */// w w w. j a v a 2 s . c o m public void getMessages() { String ipSaved = Preference.getString(context.getApplicationContext(), context.getResources().getString(R.string.shared_pref_ip)); ServerConfig utils = new ServerConfig(); utils.setServerIP(ipSaved); String deviceIdentifier = null; try { deviceIdentifier = URLEncoder.encode(deviceId, ENCODE_METHOD_UTF_8); } catch (UnsupportedEncodingException e) { Log.e(TAG, "Unsupport encoding." + e.toString()); } CommonUtils.callSecuredAPI(context, utils.getAPIServerURL() + Constants.NOTIFICATION_ENDPOINT + File.separator + deviceIdentifier, HTTP_METHODS.GET, new JSONObject(), MessageProcessor.this, Constants.NOTIFICATION_REQUEST_CODE); }
From source file:org.wso2.mdm.agent.services.MessageProcessor.java
/** * Call the message retrieval end point of the server to get messages pending. This method * will be called when there is a reply payload to be sent to the server. *///from w w w . j a v a 2s . co m public void getMessages(JSONArray replyPayload) throws AndroidAgentException { String ipSaved = Preference.getString(context.getApplicationContext(), context.getResources().getString(R.string.shared_pref_ip)); ServerConfig utils = new ServerConfig(); utils.setServerIP(ipSaved); String deviceIdentifier = null; try { deviceIdentifier = URLEncoder.encode(deviceId, ENCODE_METHOD_UTF_8); } catch (UnsupportedEncodingException e) { Log.e(TAG, "Unsupport encoding." + e.toString()); } JSONObject requestParams = new JSONObject(); if (replyPayload != null) { try { requestParams.put(LABEL_DATA, replyPayload.toString()); } catch (JSONException e) { throw new AndroidAgentException("JSON Exception in reply payload.", e); } } CommonUtils.callSecuredAPI(context, utils.getAPIServerURL() + Constants.NOTIFICATION_ENDPOINT + File.separator + deviceIdentifier, HTTP_METHODS.GET, requestParams, MessageProcessor.this, Constants.NOTIFICATION_REQUEST_CODE); }
From source file:xtuaok.sharegyazo.HttpMultipartPostRequest.java
private String convertToString(InputStream stream) { InputStreamReader streamReader = null; BufferedReader bufferReader = null; try {/*from w w w. ja va 2s. c o m*/ streamReader = new InputStreamReader(stream, "UTF-8"); bufferReader = new BufferedReader(streamReader); StringBuilder builder = new StringBuilder(); for (String line = null; (line = bufferReader.readLine()) != null;) { builder.append(line).append("\n"); } return builder.toString(); } catch (UnsupportedEncodingException e) { Log.e(LOG_TAG, e.getMessage()); } catch (IOException e) { Log.e(LOG_TAG, e.toString()); } finally { try { stream.close(); if (bufferReader != null) { bufferReader.close(); } } catch (IOException e) { // IOError Log.e(LOG_TAG, e.toString()); } } return null; }
From source file:com.cmsoftware.keyron.controlador.UsuarioFunciones.java
/** * Cambia la clave del usuario recibido por parmetros. * * @param correo Correo electrnico del ususario. * @param clave Clave del usuario.//from www . j a va2 s .c o m * @param nuevaClave Nueva clave del usuario. * @return Objeto de respuesta Json. */ public JSONObject cambiarClave(String correo, String clave, String nuevaClave) { String parametros = ""; try { parametros = "accion=" + URLEncoder.encode(ACCION_CAMBIO_CLAVE, "UTF-8") + "&correo=" + URLEncoder.encode(correo, "UTF-8") + "&clave=" + URLEncoder.encode(clave, "UTF-8") + "&nuevaClave=" + URLEncoder.encode(nuevaClave, "UTF-8"); } catch (UnsupportedEncodingException e) { System.err.println("ERROR UsuarioFunciones:128 -> " + e.toString()); Log.agregarError(e); } return json.getRespuestaAPI(ACCESO_URL_USUARIO, parametros); }
From source file:com.cmsoftware.keyron.controlador.UsuarioFunciones.java
/** * Activa un usuario.// w w w . j a v a 2 s . c o m * * @param correo Correo del administrador. * @param clave Clave del administrador. * @param cedulaUsuario Cdula del usuario a activar. * @return Objeto de respuesta Json. */ public JSONObject activarUsuario(String correo, String clave, String cedulaUsuario) { String parametros = ""; try { parametros = "accion=" + URLEncoder.encode(ACCION_ACTIVACION_USUARIO, "UTF-8") + "&correo=" + URLEncoder.encode(correo, "UTF-8") + "&clave=" + URLEncoder.encode(clave, "UTF-8") + "&cedula=" + URLEncoder.encode(cedulaUsuario, "UTF-8"); } catch (UnsupportedEncodingException e) { System.err.println("ERROR UsuarioFunciones:150 -> " + e.toString()); Log.agregarError(e); } return json.getRespuestaAPI(ACCESO_URL_USUARIO, parametros); }
From source file:com.cmsoftware.keyron.controlador.UsuarioFunciones.java
/** * Desactiva un usuario.//from w ww .j av a2 s .c o m * * @param correo Correo del administrador. * @param clave Clave del administrador. * @param cedulaUsuario Cdula del usuario a desactivar. * @return Cdigo de respuesta del web service. */ public int desactivarUsuario(String correo, String clave, String cedulaUsuario) { String parametros = ""; try { parametros = "accion=" + URLEncoder.encode(ACCION_DESACTIVACION_USUARIO, "UTF-8") + "&correo=" + URLEncoder.encode(correo, "UTF-8") + "&clave=" + URLEncoder.encode(clave, "UTF-8") + "&cedula=" + URLEncoder.encode(cedulaUsuario, "UTF-8"); JSONObject respuesta = json.getRespuestaAPI(ACCESO_URL_USUARIO, parametros); int key_error = respuesta.getInt("error"); return key_error; } catch (UnsupportedEncodingException e) { System.err.println("ERROR UsuarioFunciones:175 -> " + e.toString()); Log.agregarError(e); return -1; } }
From source file:org.seasar.mayaa.impl.cycle.web.MockServletResponse.java
public PrintWriter getWriter() { try {//from ww w . jav a2s . co m BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(getOutputStream(), getCharacterEncoding())); return new PrintWriter(writer); } catch (UnsupportedEncodingException e) { throw new IllegalStateException(e.toString()); } }
From source file:com.oplay.nohelper.volley.toolbox.JsonRequest.java
@Override protected Response<T> parseNetworkResponse(NetworkResponse response) { try {//from w ww. j av a 2 s . co m String json = new String(response.data, "UTF-8"); if (VolleyLog.DEBUG) { /*VolleyLog.e("\n[Request]:"+ getUrl() + "\n[params]:" + getParamsString(getParams()) + "\n[class]:" + mRequestEntity.getClassOfT());*/ VolleyLog.d("result is %s", json); VolleyLog.d("\nparams is %s", getParamsString(getParams())); VolleyLog.d("\nclass is %s", mRequestEntity.getClassOfT()); } return Response.success(fromJson(json, mRequestEntity.getClassOfT()), HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { if (VolleyLog.DEBUG) { VolleyLog.e("%s", e.toString()); } return Response.error(new ParseError(e)); } catch (Exception e) { if (VolleyLog.DEBUG) { VolleyLog.e("%s", e.toString()); } return Response.error(new ParseError(e)); } }
From source file:org.kuali.test.ui.components.panels.TestOperationsPanel.java
private void handleHtmlRequestDetails(HtmlRequestOperation htmlRequestOperation) { HtmlRequestDetailsDlg dlg = new HtmlRequestDetailsDlg(getMainframe(), parentDialog, htmlRequestOperation); if (dlg.isSaved()) { List<NameValuePair> params = dlg.getUrlParameters(); try {//from w ww . j a v a 2 s .c o m if (Utils.isPost(htmlRequestOperation)) { RequestParameter param = Utils.getContentParameter(htmlRequestOperation); if (Utils.isMultipart(htmlRequestOperation)) { param.setValue(Utils.buildMultipartParameterString(params)); } else { param.setValue(Utils.buildUrlEncodedParameterString(params)); } } else { htmlRequestOperation.setUrl(Utils.updateUrlParameters(htmlRequestOperation.getUrl(), params)); } parentDialog.getSaveButton().setEnabled(true); } catch (UnsupportedEncodingException ex) { LOG.warn(ex.toString(), ex); } } }