91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 8KB
    文件類(lèi)型: .java
    金幣: 1
    下載: 1 次
    發(fā)布日期: 2021-06-17
  • 語(yǔ)言: Java
  • 標(biāo)簽:

資源簡(jiǎn)介

getwxacodeunlimit 生成二維碼 并保存在本地 。獲取到access_token 可以直接使用

資源截圖

代碼片段和文件信息

package?com.wangmai.utils;

import?java.io.BufferedReader;
import?java.io.File;
import?java.io.FileNotFoundException;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?java.io.InputStream;
import?java.io.InputStreamReader;
import?java.net.URL;
import?java.net.URLConnection;
import?java.net.URLEncoder;
import?java.text.SimpleDateFormat;
import?java.util.Date;
import?java.util.HashMap;
import?java.util.List;
import?java.util.Map;

import?javax.servlet.http.HttpServletRequest;

import?org.apache.http.HttpEntity;
import?org.apache.http.HttpResponse;
import?org.apache.http.client.methods.HttpPost;
import?org.apache.http.entity.StringEntity;
import?org.apache.http.impl.client.DefaultHttpClient;
import?org.apache.http.message.BasicHeader;
import?org.apache.http.protocol.HTTP;
import?net.sf.json.JSONobject;

public?class?WeiXinQRManager?{
/**
?*?@param?reqUrl
?*????????????基礎(chǔ)的url地址
?*?@param?params
?*????????????查詢(xún)參數(shù)
?*?@return?構(gòu)建好的url
?*/

public?static?String?httpPostWithJSON(HttpServletRequest?request?String?url?String?json?String?id)
throws?Exception?{
String?result?=?null;
//?將JSON進(jìn)行UTF-8編碼以便傳輸中文
String?encoderJson?=?URLEncoder.encode(json?HTTP.UTF_8);
DefaultHttpClient?httpClient?=?new?DefaultHttpClient();
HttpPost?httpPost?=?new?HttpPost(url);
httpPost.addHeader(HTTP.CONTENT_TYPE?“application/json“);
StringEntity?se?=?new?StringEntity(json);
se.setContentType(“application/json“);
se.setContentEncoding(new?BasicHeader(HTTP.CONTENT_TYPE?“UTF-8“));
httpPost.setEntity(se);
//?httpClient.execute(httpPost);
HttpResponse?response?=?httpClient.execute(httpPost);
if?(response?!=?null)?{
HttpEntity?resEntity?=?response.getEntity();
if?(resEntity?!=?null)?{
InputStream?instreams?=?resEntity.getContent();
//?ResourceBundle?systemConfig?=
//?ResourceBundle.getBundle(“config/system“
//?Locale.getDefault());
//?String?uploadSysUrl?=
//?systemConfig.getString(“agentImgUrl“)+id+“/“;
//?File?saveFile?=?new?File(uploadSysUrl+id+“.jpg“);
String?uploadSysUrl?=?“D:\\upload“?+?“/“;
SimpleDateFormat?sdf?=?new?SimpleDateFormat(“yyyy-MM-dd“);
String?dateStr?=?sdf.format(new?Date());
String?xdPath?=?“/upload/“?+?dateStr;
String?filePath?=?request.getServletContext().getRealPath(xdPath);//?保存文件路徑
File?saveFile?=?new?File(filePath);
//?判斷這個(gè)文件(saveFile)是否存在
if?(!saveFile.exists())?{
//?如果不存在就創(chuàng)建這個(gè)文件夾
saveFile.mkdirs();
}
String?newHeadImgName?=?““;//?重新設(shè)置要保存頭像的文件名
//?獲取當(dāng)前時(shí)間
Date?d?=?new?Date();
newHeadImgName?+=?““?+?d.getTime()?+?((int)?(Math.random()?*?9000?+?1000))?+?“.jpg“;
saveToImgByInputStream(instreams?filePath?newHeadImgName);
result?=?xdPath?+?“/“?+?newHeadImgName;
}
}
return?result;
}

/*
?*?@param?instreams?二進(jìn)制流
?*?
?*?@param?imgPath?圖片的保存路徑
?*?
?*?@param?imgName?圖片的名稱(chēng)
?*?
?*?@return?1:保存正常?0:保存

評(píng)論

共有 條評(píng)論