13,100
社区成员
发帖
与我相关
我的任务
分享
public String HTTPpost(String sURL, String sPostData, byte[] bytData){
byte[] sData;
HttpConnection HTTPconn = null;
InputStream HTTPin = null;
OutputStream HTTPout = null;
try {
HTTPconn = (HttpConnection)JConnector.open(sURL);
HTTPconn.setRequestMethod(HttpConnection.POST);
HTTPout = HTTPconn.openOutputStream();
HTTPout.write((sPostData + "<data>").getBytes());
HTTPout.write(bytData);
HTTPout.close();
HTTPin = HTTPconn.openInputStream();
sData = new byte[(int)HTTPconn.getLength()];
for (int i = 0; i < sData.length;i++){
sData[i] = (byte)HTTPin.read();
};
HTTPin.close();
HTTPconn.close();
HTTPout = null; HTTPin = null; HTTPconn = null;
return new String(sData);
}catch(Exception e){
try{
if (HTTPout != null) HTTPout.close();
}catch(Exception e2){};
try{
if (HTTPin != null) HTTPin.close();
}catch(Exception e3){};
try{
if (HTTPconn != null) HTTPconn.close();
}catch(Exception e4){};
HTTPout = null; HTTPin = null; HTTPconn = null;
return null;
}
}