Try this:
public static String getURLData( String url ) {
// creates a StringBuilder to store the data
StringBuilder out = new StringBuilder();
try {
// creating the URL
URL u = new URL( url );
// openning a connection
URLConnection uCon = u.openConnection();
// getting the connection's input stream
InputStream in = uCon.getInputStream();
// a buffer to store the data
byte[] buffer = new byte[2048];
// try to insert data in the buffer until there is data to be read
while ( in.read( buffer ) != -1 ) {
// storing data...
out.append( new String( buffer ) );
}
// closing the input stream
in.close();
// exceptions...
} catch ( MalformedURLException exc ) {
exc.printStackTrace();
} catch ( IOException exc ) {
exc.printStackTrace();
} catch ( SecurityException exc ) {
exc.printStackTrace();
} catch ( IllegalArgumentException exc ) {
exc.printStackTrace();
} catch ( UnsupportedOperationException exc ) {
exc.printStackTrace();
}
// returning data
return out.toString();
}
If you need to work with a proxy you will need to do some more work, since you will need to authenticate. Here you can read something about it: How do I make HttpURLConnection use a proxy?
If you want a client that works like a browser, you can try the HttpClient from Apache HttpComponentes
Now, if you need a behavior where the server notifies the client, so you will need to use another approaches, like creating your own server and working with sockets. If you work with a regular browser you can use websockets, but it seems that is not your case.