try
{
URL u = new URL("http://www.google.com");
HttpURLConnection http_conn = (HttpURLConnection)u.openConnection();
sun.net.www.protocol.http.HttpURLConnection h;
http_conn.setDoInput(true);
http_conn.setDoOutput(true);
InputStream input = http_conn.getInputStream();
byte b [] = new byte[1024]
;
int pos = -1;
String content = "";
while((pos = input.read(b)) != -1)
{
content += new String(b, 0, pos);
}
System.out.println(content);
}
catch(Exception e)
{
e.printStackTrace();
}
when vaadin started, the code will throws Exception
java.lang.NullPointerException
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne
ction.java:773)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection
.java:661)
Run in GetUrlTestApplication Will Throws NullPointExcpetion, but if create a java Application, execute GetUrlThread Thread, The results will be correct.
The same problem will appear in the Servlet.In Vaading,What a way to get the content URL