没有合适的资源?快使用搜索试试~ 我知道了~
Rust语言HelloWorld Rust-langFFI使用案例教程.pdf
需积分: 5 0 下载量 163 浏览量
2024-11-07
16:51:45
上传
评论
收藏 3.71MB PDF 举报
温馨提示
Rust语言HelloWorld Rust-langFFI使用案例教程
资源推荐
资源详情
资源评论
rustandroidmak。[Shell/批处理],Rust 语言 HclloWorld Rust-langFFI 使用案例,scala
多线程统计文件大小,Scala求 1 到 100之间奇数的平方的和[Scala]
scala卜.载网易股票财务指标,shell写的动画效果,shell获取当前脚本执行绝对路径
[文件]Serv i ceCommun i cat i on_new. java ~ 4KB (60)
import java. io. ByteArrayOutputStream;
import java. io. InputStream;
import java. io. OutputStrecim;
import java. io. OutputStreamWriter;
import java. io. UnsupportedEncodingExcept ion;
import java. HttpURLConnection;
import java. URL;
import android, content. Context;
import android, os. AsyncTask;
import android, util. Log;
import com. fubonmon. Constants;
import com. fubonmon. LoginManager;
import com. fubonmunication. NetTool;
import com. fubon. util. Androidllti I ;
//php多城市切换
//PHP多线程批量采集下载美女图片的实现代码
public class ServiceCommunication new extends
AsyncTask<String, Integer, Object> {
private static final String tag =
z,
ServiceCommunication_new
/"
;
private Context mcontext;
private ServiceParser parser;
private String contentType;
private static final String CONTENT TYPE TEXTXML = "text/xml";
private String methodName;
private int what;
private int responscCodo = -1;
public ServiceCommunication new(Context context, ServiceParser parser) {
this, parser = parser;
this, mcontext = context;
)
protected void onPreExecute() {
)
@Override
protected Object do InBackground(String... params) {
HttpURLConnection con = null;
OutputStrcamWriter osw = null;
Inputstream receivesIream = nul1;
ByteArrayOutputStream buffStream = null;
try {
what=Integer. parselnt(params[0J ;
responseCode = -1;
if (INetTool. checkNet(mcontext)) {
Log.v (tag, "net error");
return null;
)
WebServ icePostBean postDataBean = new WebServicePostBeanO;
postDataBean
.setAction(Constants. NAME_SPACE,
methodName = params);
if (params, length > 3) {
for (int i = 3; i < params, length; i++) {
String[] nameAndValue = params[i]. split ;
Stri ng n<irne=nameAndVa 1 ue [0];
String value:"”;
if(nameAndValue. length>l) {
value:nameAndValue;
}
postDataBean. addPeirams (name, value);
)
)
String soapXML = postDataBean. toStringO;
[,og. v(tag, "soapXML:" + soapXML);
// connect
Log. v(tag, + Constants. getWebserviceHost(mcontext)
+ params);
URL = new URL(Constants. getWebserviceHost(mcontext) +
params);
con = (HttpCRLConnect ion) . openConnection();
String sCookie =
I,oginManager, get Instance(). getSessionll)();
// set cookie. sCookie is my static cookie string
Log. v(tag, "sCookie:" + sCookie);
if (sCookie != null && sCookie. length() > 0) {
con. setRcqucstPropcrty(^Cookie",
“ASP. NET_SessionId= " + sCookie
+ path=/; HttpOnly*);
)
con. setRcquestProperty C
,
Contcnt-Typc
/,
,
“text/xml;charset=utf-8");
con.setRequestMethod(^POST^);
con. setDoOutput(true);
con.setDoInput(true);
con. setUseCaches(false);
con. setConnectTimeout(5 * 1000);
osw = new OutputStrcamWri ter(con. getOutputStream(),
“utf-8〃);
osw. write(soapXML);
osw. f lushO ;
responseCode = con. getResponseCodeO ;
Log. v(tag, "responseCode— + responseCode);
if (responseCode = HttpURLConnection. HTTP OK) {
receivcStream = con. getlnputStroamO ;
if (receiveStream != null) {
contentTypc = con. gctContentTypeO ;
Log. v (tag, "contentType=" >
contentType);
if
(contentType.startsWith(CONTENT _TYPE_TEXTXML)) {
return
AndroidUtil. getRootElement(receiveStream);
)
)
)
} catch (Exception e) {
e. printStackTrace();
} finally {
try (
if (osw != null) {
osw. closeO ;
}
if (receiveStream != null) {
receiveStream. close ();
}
if (buffStream != null) {
buffStream. closeO ;
)
if (con != null) {
con. disconnect();
}
} catch (Exception e2) {
e2.printStackTrace();
import com. fubonmon. Constants;
import com. fubon. u til. AndroidUtil;
import android, os. Handler;
import android, os. Message;
import android, u til. Log;
public class ServiceParser {
private sta tic final String tag = "ServiceParser";
private Handler handler;
public void setHand1 er(Hand1 er h a n d le r):
this.handler = handler;
)
private void printResult(Element c o n te n t)(
if (content == n u l l ) [
Log. v(tag, "content is nu ll!!”);
return;
)
StringBuffer resu ltS tr = new StringBuffer();
AndroidUtil. transDomToString(content, re su ltS tr);
Log. v(tag, resultStr. toStringO );
)
public void parser(SeviceResponseBean response) {
if(handler==null) {
return;
}
Message msg = Message, obtain();
msg. what = response, what;
if (response, success) {
Element content = (Element) response. responseData;
printResult (content);
String resultElementName = response. methodName +
“Result";
Element resultElement = (Element) (content
. getElementsByTagName(resultElementName
) . itcm(O));
if (resultElement != null) {
if (response, what ==
Constants. GET_MAP_TABLE_ALL_NUM) {
//a re a dialogs items
List<List<List<Map<String, O b jec t» »
resul tList=new ArrayList<List<List<Map<String, O bject» » ();
/ / area items
List<List<Map<String, Object»>
tempResultList = new ArrayList<List<Map<String, Object»>();
NodeList childs =
resultElement. getChildNodesO ;
for (int i =0; i < childs. getLengthO ; i++)
(
if (childs. item (i). getNodeType()
= = Node. ELEMENT_NODE) {
tempResultList. add(pareserResult(chi Ids. i tem(i)));
}
)
List<List<Map<String, Object»>
0809Area=ncw ArrayList<List<Map<String, Object»> ();
_()809Area. add (tempResu 1 tLi st. get (0));
0809Area. add(tempResultList. g et(1));
resu1tList. add( 0809Area);
for(int
i=2; KtempResultList. size () ; i++) {
List<List<Map<String, Object>»
temp=new ArrayList<List<Map<String, O bject»>();
teadd(tempResultList. g e t(i));
resultList. add(temp);
)
msg. obj = resu ltL ist;
} else {
msg. obj = pareserRosult(resultElem ent);
}
msg. argl = Constants. HTTP OK;
} else {
msg. argl = Constants. HTTP NULL;
)
} else {
msg. argl = Constants. IITTP ERR;
)
handler. scndMcssagc(msg);
)
private List<Map<String, O bject» pareserResult(Node resultElement) {
List<Map<String, Object>> resultList = new ArrayList<Map<String,
剩余22页未读,继续阅读
资源评论
无敌开心
- 粉丝: 1938
- 资源: 10万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功