private String DoPostCmd(String strURL, String req) {
String result = null;
try {
URL url = new URL(strURL);
URLConnection con = url.openConnection();
con.setUseCaches(true);
con.setDoInput(true);
con.setDoOutput(true);
BufferedOutputStream out = new BufferedOutputStream(con.getOutputStream());
byte outBuf[] = req.getBytes("GB2312");
out.write(outBuf);
out.close();
BufferedInputStream in = new BufferedInputStream(con.getInputStream());
result = ReadByteStream(in);
in.close();
} catch (IOException ex) {
result = "";
} catch (Exception ex) {
result = "";
}
return (result == null ? "" : result);
}
private static String ReadByteStream(BufferedInputStream in) throws IOException {
LinkedList bufList = new LinkedList();
int size = 0;
byte buf[];
do {
buf = new byte[128];
int num = in.read(buf);
if (num == -1)
break;
size += num;
bufList.add(new mybuf(buf, num));
} while (true);
buf = new byte[size];
int pos = 0;
for (ListIterator p = bufList.listIterator(); p.hasNext();) {
mybuf b = (mybuf) p.next();
int i = 0;
while (i < b.size) {
buf[pos] = b.buf[i];
i++;
pos++;
}
}
return new String(buf, "GB2312");
}