Example usage for org.apache.http.util EncodingUtils getString

List of usage examples for org.apache.http.util EncodingUtils getString

Introduction

In this page you can find the example usage for org.apache.http.util EncodingUtils getString.

Prototype

public static String getString(byte[] bArr, int i, int i2, String str) 

Source Link

Usage

From source file:Main.java

public static String byteToString(byte[] $byte) {
    String result = EncodingUtils.getString($byte, 0, $byte.length, "EUC-KR");
    return result;
}

From source file:com.totu.unity.ProductType.java

public static void PurchaseInappItem(final String sku) {

    if (!isInit) {
        Log.d(TAG, "GoogleIAB ?");
        return;//  w  w  w.j a va 2  s . c o m
    }

    saveActivity.runOnUiThread(new Runnable() {
        public void run() {

            AsyncHttpClient client = new AsyncHttpClient();

            String url = urlPrefix + "farmdefence/getPayloadGoogleIAB.php";
            //?  ??
            RequestParams sendParams = new RequestParams();
            sendParams.put("userKeyNo", saveUserKeyNo);
            sendParams.put("sku", sku);

            client.get(url, sendParams, new AsyncHttpResponseHandler() {
                @Override
                public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {

                    String developerPayload = EncodingUtils.getString(responseBody, 0, responseBody.length,
                            "UTF-8");

                    Log.d(TAG, "? ? developer payload : " + developerPayload);
                    mHelper.launchPurchaseFlow(saveActivity, sku, 4885, mPurchaseFinishedListener,
                            developerPayload);
                }

                @Override
                public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                    Log.d(TAG, "payload error");
                }
            });
        }
    });
}

From source file:org.ardverk.daap.bio.HttpParser.java

/**
 * Read up to <tt>"\n"</tt> from an (unchunked) input stream. If the stream
 * ends before the line terminator is found, the last part of the string
 * will still be returned. If no input data available, <code>null</code> is
 * returned./*from  www. j a v a 2 s. c  om*/
 * 
 * @param inputStream
 *            the stream to read from
 * @param charset
 *            charset of HTTP protocol elements
 * 
 * @throws IOException
 *             if an I/O problem occurs
 * @return a line from the stream
 * 
 * @since 3.0
 */
public static String readLine(InputStream inputStream, String charset) throws IOException {
    LOG.trace("enter HttpParser.readLine(InputStream, String)");
    byte[] rawdata = readRawLine(inputStream);
    if (rawdata == null) {
        return null;
    }
    // strip CR and LF from the end
    int len = rawdata.length;
    int offset = 0;
    if (len > 0) {
        if (rawdata[len - 1] == '\n') {
            offset++;
            if (len > 1) {
                if (rawdata[len - 2] == '\r') {
                    offset++;
                }
            }
        }
    }
    final String result = EncodingUtils.getString(rawdata, 0, len - offset, charset);
    return result;
}

From source file:com.totu.unity.ProductType.java

static void CheckVerifyDeveloperPayload(final Purchase p) {
    AsyncHttpClient client = new AsyncHttpClient();
    String url = urlPrefix + "farmdefence/verificationGoogleIAB.php";
    //?  ??/*from w  w w  . j a v  a2s.  c o m*/
    RequestParams sendParams = new RequestParams();
    sendParams.put("userKeyNo", saveUserKeyNo);
    sendParams.put("orderId", p.getOrderId());
    sendParams.put("packageName", p.getPackageName());
    sendParams.put("productId", p.getSku());
    sendParams.put("purchaseTime", p.getPurchaseTime());
    sendParams.put("purchaseState", p.getPurchaseState());
    sendParams.put("developerPayload", p.getDeveloperPayload());
    sendParams.put("purchaseToken", p.getToken());

    client.post(url, sendParams, new AsyncHttpResponseHandler() {
        @Override
        public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
            String result = EncodingUtils.getString(responseBody, 0, responseBody.length, "UTF-8");

            Log.d(TAG, "verify return : " + result);

            //  .
            if (result.equals("0")) {
                UnityPlayer.UnitySendMessage(GoogleIAB_OBJECT, "Error", "-4885");
                return;
            }

            // ? ? ?.
            String productID = p.getSku();
            ProductType nowPurchaseItemType = CheckPurchaseItem(productID);
            // ? .
            switch (nowPurchaseItemType) {
            case managed:
                UnityPlayer.UnitySendMessage(GoogleIAB_OBJECT, "PurchaseCompletedManaged", productID); //  ?? ??  .
                break;
            case subscription:
                UnityPlayer.UnitySendMessage(GoogleIAB_OBJECT, "PurchaseCompletedSubscription", productID); //  ?? ??  .
                break;
            case unmanaged:
                mHelper.consumeAsync(p, mConsumeFinishedListener);
                break;

            }

        }

        @Override
        public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
            Log.d(TAG, "verification error");
        }
    });
}