Troubleshooting guide
223
15: Creating push applications
Read the server response. 1. To access an input stream, invoke getInputStream().
InputStream ins = conn.getInputStream();
2. Determine the size of the content. If the size of the content is non zero, open a data input
stream, and then retrieve the content.
int contentLength = conn.getContentLength();
if (contentLength > 0) {
byte[] someArray = new byte [contentLength];
DataInputStream dins = new DataInputStream(ins);
dins.readFully(someArray);
System.out.println(new String(someArray));
}
ins.close();
Close the server connection. > To indicate that the application will make no further requests to the server, invoke
disconnect()
conn.disconnect();
Task Steps