本文整理匯總了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);
}
}
示例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
}
}
示例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;
}
示例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;
}
示例5: ResponseStream
public ResponseStream(HttpResponse baseResponse, String requestUrl, long expiry) throws IOException {
this(baseResponse, HTTP.UTF_8, requestUrl, expiry);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}