当前位置: 首页>>代码示例>>Java>>正文


Java HTTP.UTF_8属性代码示例

本文整理汇总了Java中org.apache.http.protocol.HTTP.UTF_8属性的典型用法代码示例。如果您正苦于以下问题:Java HTTP.UTF_8属性的具体用法?Java HTTP.UTF_8怎么用?Java HTTP.UTF_8使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.http.protocol.HTTP的用法示例。


在下文中一共展示了HTTP.UTF_8属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: set

/**
 * Sets the value at {@code index} to {@code value}.
 */
public void set(int index, String value) throws IOException {
    Writer writer = null;
    try {
        writer = new OutputStreamWriter(newOutputStream(index), HTTP.UTF_8);
        writer.write(value);
    } finally {
        IOUtils.closeQuietly(writer);
    }
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:12,代码来源:LruDiskCache.java

示例2: createFormEntity

public HttpEntity createFormEntity() {
    try {
        return new UrlEncodedFormEntity(getParamsList(), HTTP.UTF_8);
    } catch (UnsupportedEncodingException e) {
        return null; // Actually cannot happen when using utf-8
    }
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:7,代码来源:RequestParams.java

示例3: doInBackground

@Override
protected ArrayList<Integer> doInBackground(Void... params) {
    // TODO: attempt authentication against a network service.
    try {
        HttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost(url);

        //參數
        int length = arraylist.size();
        if (length != 0){
            List<NameValuePair> parameters = new ArrayList<NameValuePair>();
            String json = new String();
            json+="[";
            for (int i = 0 ; i< length;i++) {
                json += "{\"id\":"+arraylist.get(i).ID+"}";
                if ( i != (length-1) )json +=",";
                else json+="]";
            }
            System.out.println(json);
            parameters.add(new BasicNameValuePair("name", json));
            parameters.add(new BasicNameValuePair("action","update"));
            SharedPreferences sp = getSharedPreferences("now_account", Context.MODE_PRIVATE);
            String stuNum=sp.getString("now_stu_num",null);
            parameters.add(new BasicNameValuePair("FetcherID",stuNum));
            UrlEncodedFormEntity ent = new UrlEncodedFormEntity(parameters, HTTP.UTF_8);
            post.setEntity(ent);
        }

        HttpResponse responsePOST = client.execute(post);

        HttpEntity resEntity = responsePOST.getEntity();


        if (resEntity != null) {
            result = EntityUtils.toString(resEntity);
        }
        JSONArray arr = new JSONArray(result.toString());
        ArrayList<Integer> array = new ArrayList<Integer>();
        for (int i = 0; i < arr.length(); i++) {
            JSONObject lan = arr.getJSONObject(i);
            array.add(lan.getInt("id"));
        }
        return  array;
    } catch (Exception e) {
        // TODO: handle exception
        e.getMessage();
    }
    return null;
}
 
开发者ID:Luodian,项目名称:Shared-Route,代码行数:49,代码来源:ConfirmTaskActivity.java

示例4: doInBackground

@Override
protected Boolean doInBackground(Void... voids) {
    try {
        HttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost(context.getResources().getString(R.string.url)+"/Task");

        //參數
            List<NameValuePair> parameters = new ArrayList<NameValuePair>();
            parameters.add(new BasicNameValuePair("id", String.valueOf(itemId)));
            parameters.add(new BasicNameValuePair("accepter",String.valueOf(accepterID)));
        System.out.println("accepterID="+accepterID);
            parameters.add(new BasicNameValuePair("action","confirm"));
            UrlEncodedFormEntity ent = new UrlEncodedFormEntity(parameters, HTTP.UTF_8);
            post.setEntity(ent);
        HttpResponse responsePOST = client.execute(post);

        HttpEntity resEntity = responsePOST.getEntity();


        if (resEntity != null) {
            result = EntityUtils.toString(resEntity);
        }
    }catch (Exception e){
        e.printStackTrace();
    }

   if (result!=null&&result.equals("success")) return true;
    else return false;
}
 
开发者ID:Luodian,项目名称:Shared-Route,代码行数:29,代码来源:NormalListDialog.java

示例5: ResponseStream

public ResponseStream(HttpResponse baseResponse, String requestUrl, long expiry) throws IOException {
    this(baseResponse, HTTP.UTF_8, requestUrl, expiry);
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:3,代码来源:ResponseStream.java

示例6: addPartWithCharset

public void addPartWithCharset(String key, String value, String charset) {
    if (charset == null) charset = HTTP.UTF_8;
    addPart(key, value, "text/plain; charset=" + charset);
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:4,代码来源:SimpleMultipartEntity.java

示例7: doInBackground

@Override
protected Boolean doInBackground(Void... params) {
    // TODO: attempt authentication against a network service.

    System.out.println("AAA");
    try {
        HttpClient client = new DefaultHttpClient();

        HttpPost post = new HttpPost(url);

        //參數
        if (mEmail != ""){
            List<NameValuePair> parameters = new ArrayList<NameValuePair>();
            parameters.add(new BasicNameValuePair("username", mEmail));
            parameters.add(new BasicNameValuePair("password", mPassword));
            UrlEncodedFormEntity ent = new UrlEncodedFormEntity(parameters, HTTP.UTF_8);
            post.setEntity(ent);
        }

        HttpResponse responsePOST = client.execute(post);

        HttpEntity resEntity = responsePOST.getEntity();

        if (resEntity != null) {
            result = EntityUtils.toString(resEntity);
        }
        if (result.equals("success"))
        {
            client.getConnectionManager().shutdown();
            return true;
        }
        else
        {
            return false;
        }
    } catch (IOException e) {
        // TODO: handle exception
        e.getMessage();
    }
    return false;
}
 
开发者ID:Luodian,项目名称:Shared-Route,代码行数:41,代码来源:LoginActivity.java

示例8: doInBackground

@Override
protected Boolean doInBackground(Void... params) {
    // TODO: attempt authentication against a network service.

    try {

        HttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost(url);

        //参数
        List<NameValuePair> parameters = new ArrayList<NameValuePair>();

        parameters.add(new BasicNameValuePair("Money",mMoney));
        parameters.add(new BasicNameValuePair("Name",mName));
        parameters.add(new BasicNameValuePair("Phone",mPhone));
        parameters.add(new BasicNameValuePair("PickID",mNum));
        parameters.add(new BasicNameValuePair("TaskKindID",mPackSort));
        parameters.add(new BasicNameValuePair("FetchLocation",mPickPlace));
        parameters.add(new BasicNameValuePair("SendLocation",mDelieverPlace));
        parameters.add(new BasicNameValuePair("FetchTime",mPickTime));
        parameters.add(new BasicNameValuePair("SendTime",mDelieverTime));
        int whichPay;
        if (mPayPath.equals("zhifubao")){
            whichPay=0;
        }
        else if(mPayPath.equals("wechat")){
            whichPay=1;
        }else {
            whichPay=2;         //虚拟货币
        }
        parameters.add(new BasicNameValuePair("WhichPay",String.valueOf(whichPay)));
        parameters.add(new BasicNameValuePair("Remark",mRemark));
        parameters.add(new BasicNameValuePair("PublisherID",mStuNum));
        parameters.add(new BasicNameValuePair("PromiseMoney",mSecurityMoney));
        parameters.add(new BasicNameValuePair("action", "submit"));

        UrlEncodedFormEntity ent = new UrlEncodedFormEntity(parameters, HTTP.UTF_8);
        post.setEntity(ent);

        HttpResponse responsePOST = client.execute(post);

        HttpEntity resEntity = responsePOST.getEntity();

        if (resEntity != null) {
            result = EntityUtils.toString(resEntity);
        }
        if (result.toString().equals("success"))
        {
            client.getConnectionManager().shutdown();
            return true;
        }
        else
        {
            return false;
        }
    } catch (IOException e) {
        // TODO: handle exception
        e.getMessage();
    }
    return false;
}
 
开发者ID:Luodian,项目名称:Shared-Route,代码行数:61,代码来源:PayBillActivity.java

示例9: doInBackground

@Override
        protected ArrayList<listItem> doInBackground(Void... pa) {
            String result = null;
            String path = getResources().getString(R.string.url)+"/Task";
            HttpURLConnection con = null;
            InputStream in = null;
            try {
                HttpClient client = new DefaultHttpClient();
                HttpPost post = new HttpPost(path);
                List<NameValuePair> parameters = new ArrayList<>();
//                    String json = new String();
//                    json += "[";
//                    for (int i = 0; i < length; i++) {
//                        json += "{\"id\":" + itemPublishList.get(i).ID + "}";
//                        if (i != (length - 1)) json += ",";
//                        else json += "]";
//                    }
//                    System.out.println(json);
//                    parameters.add(new BasicNameValuePair("name", json));
                SharedPreferences sp = getSharedPreferences("now_account", Context.MODE_PRIVATE);
                String stuNum=sp.getString("now_stu_num",null);
                parameters.add(new BasicNameValuePair("action", "publishpost"));
                parameters.add(new BasicNameValuePair("PublisherID", stuNum));
                UrlEncodedFormEntity ent = new UrlEncodedFormEntity(parameters, HTTP.UTF_8);
                post.setEntity(ent);
                HttpResponse responsePOST = client.execute(post);
                HttpEntity resEntity = responsePOST.getEntity();
                if (resEntity != null) {
                    result = EntityUtils.toString(resEntity);
                }
                JSONArray arr = new JSONArray(result.toString());
                if (myOrders == null) myOrders = new ArrayList<>();
                else  myOrders.clear();
                for (int i = 0; i < arr.length(); i++) {
                    JSONObject lan = arr.getJSONObject(i);
                    listItem item = new listItem();
                    item.ID = lan.getInt("ID");
                    item.Money = lan.getDouble("Money");
                    item.PickID = lan.getString("PickID");
                    item.TaskKindID = lan.getString("TaskkindID");
                    item.PublisherName = lan.getString("PublisherName");
                    item.PublisherPhone = lan.getString("PublisherPhone");
                    item.FetchTime = lan.getString("FetchTime");
                    item.FetchLocation = lan.getString("FetchLocation");
                    item.FetcherPhone = lan.getString("FetcherPhone");
                    item.FetcherName = lan.getString("FetcherName");
                    item.FetcherID = lan.getString("FetcherID");
                    item.SendTime = lan.getString("SendTime");
                    item.SendLocation = lan.getString("SendLocation");
                    item.PublisherID = lan.getString("PublisherID");
                    item.PromiseMoney = lan.getDouble("PromiseMoney");
                    item.status = lan.getInt("Status");
                    myOrders.add(item);
                }
                return (ArrayList<listItem>) myOrders;
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }
 
开发者ID:Luodian,项目名称:Shared-Route,代码行数:60,代码来源:MyPublishOrder.java

示例10: doInBackground

@Override
        protected ArrayList<listItem> doInBackground(Void ... pa) {
            String result = null;
            String path = getResources().getString(R.string.url)+"/Task";
            try
            {
                HttpClient client = new DefaultHttpClient();
                HttpPost post = new HttpPost(path);
                List<NameValuePair> parameters = new ArrayList<NameValuePair>();
//                    String json = new String();
//                    json += "[";
//                    for (int i = 0; i < length; i++) {
//                        json += "{\"id\":" + itemPublishList.get(i).ID + "}";
//                        if (i != (length - 1)) json += ",";
//                        else json += "]";
//                    }
//                    System.out.println(json);
//                    parameters.add(new BasicNameValuePair("name", json));
                parameters.add(new BasicNameValuePair("action", "fetchpost"));
                SharedPreferences sp = getSharedPreferences("now_account", Context.MODE_PRIVATE);
                String stuNum=sp.getString("now_stu_num",null);
                parameters.add(new BasicNameValuePair("FetcherID", stuNum));
                UrlEncodedFormEntity ent = new UrlEncodedFormEntity(parameters, HTTP.UTF_8);
                post.setEntity(ent);
                HttpResponse responsePOST = client.execute(post);
                HttpEntity resEntity = responsePOST.getEntity();
                if (resEntity != null) {
                    result = EntityUtils.toString(resEntity);
                }
                JSONArray arr = new JSONArray(result.toString());
                if (myOrders == null) myOrders = new ArrayList<listItem>();
                else myOrders.clear();
                for (int i = 0; i < arr.length(); i++) {
                    JSONObject lan = arr.getJSONObject(i);
                    listItem item = new listItem();
                    item.ID = lan.getInt("ID");
                    item.Money = lan.getDouble("Money");
                    item.PickID = lan.getString("PickID");
                    item.TaskKindID = lan.getString("TaskkindID");
                    item.PublisherName = lan.getString("PublisherName");
                    item.PublisherPhone = lan.getString("PublisherPhone");
                    item.FetchTime = lan.getString("FetchTime");
                    item.FetchLocation = lan.getString("FetchLocation");
                    item.FetcherPhone = lan.getString("FetcherPhone");
                    item.FetcherName = lan.getString("FetcherName");
                    item.FetcherID = lan.getString("FetcherID");
                    item.SendTime = lan.getString("SendTime");
                    item.SendLocation = lan.getString("SendLocation");
                    item.PublisherID = lan.getString("PublisherID");
                    item.PromiseMoney = lan.getDouble("PromiseMoney");
                    item.status = lan.getInt("Status");
                    myOrders.add(item);
                }
                return  (ArrayList<listItem>) myOrders;
            }catch (Exception e){
                e.printStackTrace();
            }
            return null;
        }
 
开发者ID:Luodian,项目名称:Shared-Route,代码行数:59,代码来源:MyFinishedActivity.java

示例11: doInBackground

@Override
protected Boolean doInBackground(Void... params) {
    // TODO: attempt authentication against a network service.

    try {

        HttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost(url);

        //参数
        List<NameValuePair> parameters = new ArrayList<NameValuePair>();

        parameters.add(new BasicNameValuePair("UserID",userID));
        parameters.add(new BasicNameValuePair("ContactInfo",contact));
        parameters.add(new BasicNameValuePair("BugsType",bugType));
        parameters.add(new BasicNameValuePair("Comment",bugInfo));
        parameters.add(new BasicNameValuePair("action", "submitBug"));

        UrlEncodedFormEntity ent = new UrlEncodedFormEntity(parameters, HTTP.UTF_8);
        post.setEntity(ent);

        HttpResponse responsePOST = client.execute(post);

        HttpEntity resEntity = responsePOST.getEntity();

        if (resEntity != null) {
            result = EntityUtils.toString(resEntity);
        }
        if (result.equals("success"))
        {
            client.getConnectionManager().shutdown();
            return true;
        }
        else
        {
            return false;
        }
    } catch (IOException e) {
        // TODO: handle exception
        e.getMessage();
    }
    return false;
}
 
开发者ID:Luodian,项目名称:Shared-Route,代码行数:43,代码来源:BugSendActivity.java

示例12: doInBackground

@Override
protected Boolean doInBackground(Void... params) {
    // TODO: attempt authentication against a network service.
    try {
        BasicHttpParams httpParams = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParams, REQUEST_TIMEOUT);
        HttpConnectionParams.setSoTimeout(httpParams, SO_TIMEOUT);
        HttpClient client = new DefaultHttpClient(httpParams);
        HttpPost post = new HttpPost(url);

        //参数
        List<NameValuePair> parameters = new ArrayList<NameValuePair>();

        parameters.add(new BasicNameValuePair("Name",this.name));
        parameters.add(new BasicNameValuePair("UserID",this.stuNum));
        parameters.add(new BasicNameValuePair("Phone",this.phone));
        parameters.add(new BasicNameValuePair("ID",this.inviteCode));
        parameters.add(new BasicNameValuePair("Password",this.password));
        parameters.add(new BasicNameValuePair("action", "registe"));           //数据库应该建表

        UrlEncodedFormEntity ent = new UrlEncodedFormEntity(parameters, HTTP.UTF_8);
        post.setEntity(ent);

        HttpResponse responsePOST = client.execute(post);

        HttpEntity resEntity = responsePOST.getEntity();

        if (resEntity != null) {
            result = EntityUtils.toString(resEntity);
        }
        if (result.toString().equals("success"))
        {
            client.getConnectionManager().shutdown();
            return true;
        }
        else
        {
            return false;
        }
    } catch (IOException e) {
        // TODO: handle exception
        e.getMessage();
    }
    return false;
}
 
开发者ID:Luodian,项目名称:Shared-Route,代码行数:45,代码来源:RegisterActivity.java

示例13: doInBackground

@Override
        protected Void doInBackground(Void... voids) {
            String result = null;
//            String path = "http://47.95.194.146:8080/sharedroot_server/Task";
            String path = getResources().getString(R.string.url)+"/Task";
            HttpURLConnection con = null;
            InputStream in = null;
            try {
                HttpClient client = new DefaultHttpClient();
                HttpPost post = new HttpPost(path);


                List<NameValuePair> parameters = new ArrayList<NameValuePair>();
                parameters.add(new BasicNameValuePair("action", "rank"));
                parameters.add(new BasicNameValuePair("parameter",PorA));
//                SharedPreferences sp = getSharedPreferences("now_account", Context.MODE_PRIVATE);
//                String stuNum=sp.getString("now_stu_num",null);
//                parameters.add(new BasicNameValuePair("PublisherID", stuNum));
                UrlEncodedFormEntity ent = new UrlEncodedFormEntity(parameters, HTTP.UTF_8);
                post.setEntity(ent);
                HttpResponse responsePOST = client.execute(post);
                HttpEntity resEntity = responsePOST.getEntity();
                if (resEntity != null) {
                    result = EntityUtils.toString(resEntity);
                }
                JSONArray arr = new JSONArray(result.toString());
                itemList = new ArrayList<Client>();
                itemListOthers = new ArrayList<Client>();
                for (int i = 0; i < arr.length(); i++) {
                    JSONObject lan = arr.getJSONObject(i);

                    String id =  lan.getString("UserID");
                    String name = lan.getString("Name");
                    int publishtasknum = lan.getInt("PublishTaskNum");
                    int fetchtasknum = lan.getInt("FetchTaskNum");
                    Client client1 = new Client(id,name,fetchtasknum,publishtasknum);
                    client1.rank = i + 1;
                    if (i<=2) itemList.add(client1);
                    else itemListOthers.add(client1);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }
 
开发者ID:Luodian,项目名称:Shared-Route,代码行数:45,代码来源:MyRank.java


注:本文中的org.apache.http.protocol.HTTP.UTF_8属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。