我没有java经验,我得到了一些XML交互的工作示例代码,我唯一的问题是我需要POST数据(用户名/密码)
相关代码是:
static String myUrlString = "http://www.grupoandroid.com/interface/mobile/index.php";
protected TheParser(){
try {
this.myUrl = new URL(myUrlString);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
protected InputStream getInputStream() {
try {
return myUrl.openConnection().getInputStream();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
答案 0 :(得分:1)
您可以使用HttpURLConnection
protected InputStream getInputStream() {
try {
HttpURLConnection con = new HttpURLConnection(myUrl);
con.setRequestMethod("POST");
//writeout data to the output stream
return con.getInputStream();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
答案 1 :(得分:0)