I am not sure why that is happening, but i bet the devs over at the android-developers group might be able to help you out
Good luck ---snctln On May 25, 10:28 pm, Ajeet Singh <[email protected]> wrote: > Hi Everyone, > > I got one sample program [For getting HTML source] which works well > (means it prints all HTML source) when I run it as a Java Program, but > it gives error [unknown socket error -1 ] when I run it as a Android > program. > > the code is here :- > > --------------------------------------------------------------------------------------------- > > public static String getHTML(String urlToRead) { > URL url; // The URL to read > HttpURLConnection conn; // The actual connection to the web > page > BufferedReader rd; // Used to read results from the web page > String line; // An individual line of the web page HTML > String result = ""; // A long string containing all the HTML > try { > url = new URL(urlToRead); > conn = (HttpURLConnection) url.openConnection(); > conn.setRequestMethod("GET"); > rd = new BufferedReader(new InputStreamReader > (conn.getInputStream())); > while ((line = rd.readLine()) != null) { > > result += line; > } > rd.close(); > } catch (Exception e) { > e.printStackTrace(); > } > System.out.println(result); > return result; > } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
