org.apache.http.util.EncodingUtils Java Examples
The following examples show how to use
org.apache.http.util.EncodingUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CordovaResourceApi.java From phonegapbootcampsite with MIT License | 6 votes |
private OpenForReadResult readDataUri(Uri uri) { String uriAsString = uri.getSchemeSpecificPart(); int commaPos = uriAsString.indexOf(','); if (commaPos == -1) { return null; } String[] mimeParts = uriAsString.substring(0, commaPos).split(";"); String contentType = null; boolean base64 = false; if (mimeParts.length > 0) { contentType = mimeParts[0]; } for (int i = 1; i < mimeParts.length; ++i) { if ("base64".equalsIgnoreCase(mimeParts[i])) { base64 = true; } } String dataPartAsString = uriAsString.substring(commaPos + 1); byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8"); InputStream inputStream = new ByteArrayInputStream(data); return new OpenForReadResult(uri, inputStream, contentType, data.length, null); }
Example #2
Source File: CordovaResourceApi.java From reader with MIT License | 6 votes |
private OpenForReadResult readDataUri(Uri uri) { String uriAsString = uri.getSchemeSpecificPart(); int commaPos = uriAsString.indexOf(','); if (commaPos == -1) { return null; } String[] mimeParts = uriAsString.substring(0, commaPos).split(";"); String contentType = null; boolean base64 = false; if (mimeParts.length > 0) { contentType = mimeParts[0]; } for (int i = 1; i < mimeParts.length; ++i) { if ("base64".equalsIgnoreCase(mimeParts[i])) { base64 = true; } } String dataPartAsString = uriAsString.substring(commaPos + 1); byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8"); InputStream inputStream = new ByteArrayInputStream(data); return new OpenForReadResult(uri, inputStream, contentType, data.length, null); }
Example #3
Source File: CordovaResourceApi.java From reader with MIT License | 6 votes |
private OpenForReadResult readDataUri(Uri uri) { String uriAsString = uri.getSchemeSpecificPart(); int commaPos = uriAsString.indexOf(','); if (commaPos == -1) { return null; } String[] mimeParts = uriAsString.substring(0, commaPos).split(";"); String contentType = null; boolean base64 = false; if (mimeParts.length > 0) { contentType = mimeParts[0]; } for (int i = 1; i < mimeParts.length; ++i) { if ("base64".equalsIgnoreCase(mimeParts[i])) { base64 = true; } } String dataPartAsString = uriAsString.substring(commaPos + 1); byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8"); InputStream inputStream = new ByteArrayInputStream(data); return new OpenForReadResult(uri, inputStream, contentType, data.length, null); }
Example #4
Source File: CordovaResourceApi.java From cordova-amazon-fireos with Apache License 2.0 | 6 votes |
private OpenForReadResult readDataUri(Uri uri) { String uriAsString = uri.getSchemeSpecificPart(); int commaPos = uriAsString.indexOf(','); if (commaPos == -1) { return null; } String[] mimeParts = uriAsString.substring(0, commaPos).split(";"); String contentType = null; boolean base64 = false; if (mimeParts.length > 0) { contentType = mimeParts[0]; } for (int i = 1; i < mimeParts.length; ++i) { if ("base64".equalsIgnoreCase(mimeParts[i])) { base64 = true; } } String dataPartAsString = uriAsString.substring(commaPos + 1); byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8"); InputStream inputStream = new ByteArrayInputStream(data); return new OpenForReadResult(uri, inputStream, contentType, data.length, null); }
Example #5
Source File: ResourceManager.java From letv with Apache License 2.0 | 6 votes |
public static String readCountryFromAsset(Context context, String assetName) { String content = ""; try { InputStream is = context.getAssets().open(assetName); if (is == null) { return content; } DataInputStream dIs = new DataInputStream(is); byte[] buffer = new byte[dIs.available()]; dIs.read(buffer); content = EncodingUtils.getString(buffer, "UTF-8"); is.close(); return content; } catch (IOException e) { e.printStackTrace(); return content; } }
Example #6
Source File: WawlOverrides.java From kimai-android with MIT License | 6 votes |
public static void loadWebapp(WebView webView, AppSettings appSettings, boolean doLogin) { Context context = webView.getContext(); Uri url; try { url = Uri.parse(appSettings.getProfilePathFull()); } catch (Exception e) { webView.loadData(context.getString(R.string.no_valid_path), "text/html", "UTF-16"); return; } String url_s = url.toString(); if (appSettings.isProfileEmpty()) { webView.loadData(context.getString(R.string.no_valid_path), "text/html", "UTF-16"); } else { webView.loadUrl(url_s); if (doLogin) { url_s += "?a=checklogin"; String postData = "name=" + appSettings.getProfileLoginUsername() + "&password=" + appSettings.getProfileLoginPassword(); webView.postUrl(url_s, EncodingUtils.getBytes(postData, "base64")); } } }
Example #7
Source File: CordovaResourceApi.java From phonegap-plugin-loading-spinner with Apache License 2.0 | 6 votes |
private OpenForReadResult readDataUri(Uri uri) { String uriAsString = uri.getSchemeSpecificPart(); int commaPos = uriAsString.indexOf(','); if (commaPos == -1) { return null; } String[] mimeParts = uriAsString.substring(0, commaPos).split(";"); String contentType = null; boolean base64 = false; if (mimeParts.length > 0) { contentType = mimeParts[0]; } for (int i = 1; i < mimeParts.length; ++i) { if ("base64".equalsIgnoreCase(mimeParts[i])) { base64 = true; } } String dataPartAsString = uriAsString.substring(commaPos + 1); byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8"); InputStream inputStream = new ByteArrayInputStream(data); return new OpenForReadResult(uri, inputStream, contentType, data.length, null); }
Example #8
Source File: CordovaResourceApi.java From CordovaYoutubeVideoPlayer with MIT License | 6 votes |
private OpenForReadResult readDataUri(Uri uri) { String uriAsString = uri.getSchemeSpecificPart(); int commaPos = uriAsString.indexOf(','); if (commaPos == -1) { return null; } String[] mimeParts = uriAsString.substring(0, commaPos).split(";"); String contentType = null; boolean base64 = false; if (mimeParts.length > 0) { contentType = mimeParts[0]; } for (int i = 1; i < mimeParts.length; ++i) { if ("base64".equalsIgnoreCase(mimeParts[i])) { base64 = true; } } String dataPartAsString = uriAsString.substring(commaPos + 1); byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8"); InputStream inputStream = new ByteArrayInputStream(data); return new OpenForReadResult(uri, inputStream, contentType, data.length, null); }
Example #9
Source File: CordovaResourceApi.java From chappiecast with Mozilla Public License 2.0 | 6 votes |
private OpenForReadResult readDataUri(Uri uri) { String uriAsString = uri.getSchemeSpecificPart(); int commaPos = uriAsString.indexOf(','); if (commaPos == -1) { return null; } String[] mimeParts = uriAsString.substring(0, commaPos).split(";"); String contentType = null; boolean base64 = false; if (mimeParts.length > 0) { contentType = mimeParts[0]; } for (int i = 1; i < mimeParts.length; ++i) { if ("base64".equalsIgnoreCase(mimeParts[i])) { base64 = true; } } String dataPartAsString = uriAsString.substring(commaPos + 1); byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8"); InputStream inputStream = new ByteArrayInputStream(data); return new OpenForReadResult(uri, inputStream, contentType, data.length, null); }
Example #10
Source File: CordovaResourceApi.java From bluemix-parking-meter with MIT License | 6 votes |
private OpenForReadResult readDataUri(Uri uri) { String uriAsString = uri.getSchemeSpecificPart(); int commaPos = uriAsString.indexOf(','); if (commaPos == -1) { return null; } String[] mimeParts = uriAsString.substring(0, commaPos).split(";"); String contentType = null; boolean base64 = false; if (mimeParts.length > 0) { contentType = mimeParts[0]; } for (int i = 1; i < mimeParts.length; ++i) { if ("base64".equalsIgnoreCase(mimeParts[i])) { base64 = true; } } String dataPartAsString = uriAsString.substring(commaPos + 1); byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8"); InputStream inputStream = new ByteArrayInputStream(data); return new OpenForReadResult(uri, inputStream, contentType, data.length, null); }
Example #11
Source File: CordovaResourceApi.java From IoTgo_Android_App with MIT License | 6 votes |
private OpenForReadResult readDataUri(Uri uri) { String uriAsString = uri.getSchemeSpecificPart(); int commaPos = uriAsString.indexOf(','); if (commaPos == -1) { return null; } String[] mimeParts = uriAsString.substring(0, commaPos).split(";"); String contentType = null; boolean base64 = false; if (mimeParts.length > 0) { contentType = mimeParts[0]; } for (int i = 1; i < mimeParts.length; ++i) { if ("base64".equalsIgnoreCase(mimeParts[i])) { base64 = true; } } String dataPartAsString = uriAsString.substring(commaPos + 1); byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8"); InputStream inputStream = new ByteArrayInputStream(data); return new OpenForReadResult(uri, inputStream, contentType, data.length, null); }
Example #12
Source File: CordovaResourceApi.java From L.TileLayer.Cordova with MIT License | 6 votes |
private OpenForReadResult readDataUri(Uri uri) { String uriAsString = uri.getSchemeSpecificPart(); int commaPos = uriAsString.indexOf(','); if (commaPos == -1) { return null; } String[] mimeParts = uriAsString.substring(0, commaPos).split(";"); String contentType = null; boolean base64 = false; if (mimeParts.length > 0) { contentType = mimeParts[0]; } for (int i = 1; i < mimeParts.length; ++i) { if ("base64".equalsIgnoreCase(mimeParts[i])) { base64 = true; } } String dataPartAsString = uriAsString.substring(commaPos + 1); byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8"); InputStream inputStream = new ByteArrayInputStream(data); return new OpenForReadResult(uri, inputStream, contentType, data.length, null); }
Example #13
Source File: CordovaResourceApi.java From wildfly-samples with MIT License | 6 votes |
private OpenForReadResult readDataUri(Uri uri) { String uriAsString = uri.getSchemeSpecificPart(); int commaPos = uriAsString.indexOf(','); if (commaPos == -1) { return null; } String[] mimeParts = uriAsString.substring(0, commaPos).split(";"); String contentType = null; boolean base64 = false; if (mimeParts.length > 0) { contentType = mimeParts[0]; } for (int i = 1; i < mimeParts.length; ++i) { if ("base64".equalsIgnoreCase(mimeParts[i])) { base64 = true; } } String dataPartAsString = uriAsString.substring(commaPos + 1); byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8"); InputStream inputStream = new ByteArrayInputStream(data); return new OpenForReadResult(uri, inputStream, contentType, data.length, null); }
Example #14
Source File: CordovaResourceApi.java From crosswalk-cordova-android with Apache License 2.0 | 6 votes |
private OpenForReadResult readDataUri(Uri uri) { String uriAsString = uri.getSchemeSpecificPart(); int commaPos = uriAsString.indexOf(','); if (commaPos == -1) { return null; } String[] mimeParts = uriAsString.substring(0, commaPos).split(";"); String contentType = null; boolean base64 = false; if (mimeParts.length > 0) { contentType = mimeParts[0]; } for (int i = 1; i < mimeParts.length; ++i) { if ("base64".equalsIgnoreCase(mimeParts[i])) { base64 = true; } } String dataPartAsString = uriAsString.substring(commaPos + 1); byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8"); InputStream inputStream = new ByteArrayInputStream(data); return new OpenForReadResult(uri, inputStream, contentType, data.length, null); }
Example #15
Source File: URIUtil.java From bintray-client-java with Apache License 2.0 | 5 votes |
/** * Unescape and decode a given string regarded as an escaped string with the * default protocol charset. * * @param escaped a string * @return the unescaped string * @throws HttpException if the string cannot be decoded (invalid) */ public static String decode(String escaped) throws HttpException { try { byte[] rawdata = URLCodec.decodeUrl(EncodingUtils.getAsciiBytes(escaped)); return EncodingUtils.getString(rawdata, UTF8_CHARSET_NAME); } catch (DecoderException e) { throw new HttpException(e.getMessage()); } }
Example #16
Source File: Boundary.java From barterli_android with Apache License 2.0 | 5 votes |
Boundary(String boundary) { if (TextUtils.isEmpty(boundary)) { boundary = generateBoundary(); } this.boundary = boundary; final String starting = "--" + boundary + MultipartEntity.CRLF; //$NON-NLS-1$ final String closing = "--" + boundary + "--" + MultipartEntity.CRLF; //$NON-NLS-1$ startingBoundary = EncodingUtils.getAsciiBytes(starting); closingBoundary = EncodingUtils.getAsciiBytes(closing); }
Example #17
Source File: StringPart.java From Onosendai with Apache License 2.0 | 5 votes |
/** * Gets the content in bytes. Bytes are lazily created to allow the charset to be changed * after the part is created. * * @return the content in bytes */ private byte[] getContent() { if (this.content == null) { this.content = EncodingUtils.getBytes(this.value, getCharSet()); } return this.content; }
Example #18
Source File: Part.java From Onosendai with Apache License 2.0 | 5 votes |
/** * Write the content disposition header to the specified output stream * * @param out The output stream * @throws IOException If an IO problem occurs. */ protected void sendDispositionHeader(final OutputStream out) throws IOException { out.write(CONTENT_DISPOSITION_BYTES); out.write(QUOTE_BYTES); out.write(EncodingUtils.getAsciiBytes(getName())); out.write(QUOTE_BYTES); }
Example #19
Source File: Boundary.java From volley with Apache License 2.0 | 5 votes |
Boundary(String boundary) { if (TextUtils.isEmpty(boundary)) { boundary = generateBoundary(); } this.boundary = boundary; final String starting = "--" + boundary + MultipartEntity.CRLF; //$NON-NLS-1$ final String closing = "--" + boundary + "--" + MultipartEntity.CRLF; //$NON-NLS-1$ startingBoundary = EncodingUtils.getAsciiBytes(starting); closingBoundary = EncodingUtils.getAsciiBytes(closing); }
Example #20
Source File: DesEncryption.java From AndroidAppCodeFramework with Apache License 2.0 | 5 votes |
public byte[] Decode(byte[] byteMiWen, int len) { int i2; byte[] dataByte = new byte[len + 8]; // 密文 DesEncryption m = new DesEncryption(); i2 = m.DECRYPT(DesEncryption.strDefaultKey.getBytes(), dataByte,byteMiWen, len); byte[] byteMingW = new byte[i2]; System.arraycopy(dataByte, 0, byteMingW, 0, i2); Log.d(TAG, "mingWen = " + EncodingUtils.getString(byteMingW, "UTF-8")); return byteMingW; }
Example #21
Source File: DesEncryption.java From AndroidAppCodeFramework with Apache License 2.0 | 5 votes |
public byte[] Encode(byte[] byteMingWen, int len) { int i1; byte[] dataByte = new byte[len + 8]; i1 = ENCRYPT(strDefaultKey.getBytes(), byteMingWen, dataByte, len); byte[] byteMiW = new byte[i1]; System.arraycopy(dataByte, 0, byteMiW, 0, i1); Log.d(TAG, "miWen = " + EncodingUtils.getString(byteMiW, "UTF-8")); return byteMiW; }
Example #22
Source File: Part.java From Onosendai with Apache License 2.0 | 5 votes |
/** * Write the content type header to the specified output stream * @param out The output stream * @throws IOException If an IO problem occurs. */ protected void sendContentTypeHeader(final OutputStream out) throws IOException { final String contentType = getContentType(); if (contentType != null) { out.write(CRLF_BYTES); out.write(CONTENT_TYPE_BYTES); out.write(EncodingUtils.getAsciiBytes(contentType)); final String charSet = getCharSet(); if (charSet != null) { out.write(CHARSET_BYTES); out.write(EncodingUtils.getAsciiBytes(charSet)); } } }
Example #23
Source File: Part.java From Onosendai with Apache License 2.0 | 5 votes |
/** * Write the content transfer encoding header to the specified * output stream * * @param out The output stream * @throws IOException If an IO problem occurs. */ protected void sendTransferEncodingHeader(final OutputStream out) throws IOException { final String transferEncoding = getTransferEncoding(); if (transferEncoding != null) { out.write(CRLF_BYTES); out.write(CONTENT_TRANSFER_ENCODING_BYTES); out.write(EncodingUtils.getAsciiBytes(transferEncoding)); } }
Example #24
Source File: DesEncryption.java From AndroidAppCodeFramework with Apache License 2.0 | 5 votes |
public byte[] Decode(byte[] byteMiWen, int len) { int i2; byte[] dataByte = new byte[len + 8]; // 密文 DesEncryption m = new DesEncryption(); i2 = m.DECRYPT(DesEncryption.strDefaultKey.getBytes(), dataByte,byteMiWen, len); byte[] byteMingW = new byte[i2]; System.arraycopy(dataByte, 0, byteMingW, 0, i2); Log.d(TAG, "mingWen = " + EncodingUtils.getString(byteMingW, "UTF-8")); return byteMingW; }
Example #25
Source File: DesEncryption.java From AndroidAppCodeFramework with Apache License 2.0 | 5 votes |
public byte[] Encode(byte[] byteMingWen, int len) { int i1; byte[] dataByte = new byte[len + 8]; i1 = ENCRYPT(strDefaultKey.getBytes(), byteMingWen, dataByte, len); byte[] byteMiW = new byte[i1]; System.arraycopy(dataByte, 0, byteMiW, 0, i1); Log.d(TAG, "miWen = " + EncodingUtils.getString(byteMiW, "UTF-8")); return byteMiW; }
Example #26
Source File: InputStreamPart.java From Onosendai with Apache License 2.0 | 5 votes |
@Override protected void sendDispositionHeader (final OutputStream out) throws IOException { super.sendDispositionHeader(out); out.write(EncodingUtils.getAsciiBytes("; filename=")); out.write(QUOTE_BYTES); out.write(EncodingUtils.getAsciiBytes(this.filename)); out.write(QUOTE_BYTES); }
Example #27
Source File: MultipartEntity.java From Onosendai with Apache License 2.0 | 5 votes |
/** * Returns the MIME boundary string that is used to demarcate boundaries of * this part. The first call to this method will implicitly create a new * boundary string. To create a boundary string first the * HttpMethodParams.MULTIPART_BOUNDARY parameter is considered. Otherwise * a random one is generated. * * @return The boundary string of this entity in ASCII encoding. */ protected byte[] getMultipartBoundary() { if (this.multipartBoundary == null) { String temp = null; if (this.params != null) { temp = (String) this.params.getParameter(MULTIPART_BOUNDARY); } if (temp != null) { this.multipartBoundary = EncodingUtils.getAsciiBytes(temp); } else { this.multipartBoundary = generateMultipartBoundary(); } } return this.multipartBoundary; }
Example #28
Source File: MultipartEntity.java From Onosendai with Apache License 2.0 | 5 votes |
@Override public Header getContentType() { final StringBuffer buffer = new StringBuffer(MULTIPART_FORM_CONTENT_TYPE); buffer.append("; boundary="); buffer.append(EncodingUtils.getAsciiString(getMultipartBoundary())); return new BasicHeader(HTTP.CONTENT_TYPE, buffer.toString()); }
Example #29
Source File: RetroWebView.java From retrowatch with Apache License 2.0 | 4 votes |
private void actionLoadWithPost(String url, String postData) { mWebView.postUrl(url, EncodingUtils.getBytes(postData, "BASE64")); }
Example #30
Source File: BasePart.java From barterli_android with Apache License 2.0 | 4 votes |
private static void append(ByteArrayBuffer buf, String data) { append(buf, EncodingUtils.getAsciiBytes(data)); }