Hi Guys,
Thanks for the suggestions
I have tried it with the following code in my serialEvent() function
- try
- {
- URL url= new URL(UpdateURL);
- URLConnection connection = url.openConnection();
- connection.setRequestProperty("User-Agent", "I am a real browser like Mozilla or MSIE" );
- String[] results = loadStrings(connection.getInputStream());
- println(results);
- }
- catch (Exception e) // MalformedURL, IO
- {
- println("HTTP Error");
- e.printStackTrace();
- }
which works nicely, however I am looking for a more elegant solution. Especially as I am trying to keep this free of imported libraries. So I tried the following which sort of works but doesnt give the expected output
- String[] result = loadStrings(UpdateURL);
- if (result == null);
{
- println("Network communications error ");
- }
- if (result != null);
- {
- println("Server response "+ result[0]);
- }
For output on every line I get
Network communications error
Server response e.g 2091
I don't understand where I am going wrong. I thought it would just show Network communications error when there was an error and the result of the loadstrings i.e the number when it worked.
But I get both