in = new DataInputStream(conn.getInputStream());
String str = "";
while (in.available() > 0) {
str += in.readUTF();
}
in = new DataInputStream(conn.getInputStream());
String str = "";
while (in.available() > 0) {
str2 += Bytes.toString(in.readBytes());
}
I cannot read any response from my php page with two methods above.
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
String str2="";
while ( (str += in.readLine()) != null && in.ready()){}
And only this method can works.
Can someone tell me what it is happening either there's the problem of inputstream ,type or charset. Thanks!!
in.available()is also probably not something you should check. That will return false if the server response is not in yet. Just read without the check. It will block until enough data is available.