There is a method that i am using to get a website html source code. this method works fine in a simple java project, but in an android project "indexoutofboundsexception index 0 size 0" exeption accurs.
the method and the log included:
private String getUrlSource(String url_str) throws Exception {
String htmlText="";
BufferedReader in = null;
try {
URL url = new URL(url_str);
URLConnection spoof = url.openConnection();
spoof.setRequestProperty( "User-Agent", "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; H010818)" );
in = new BufferedReader(new InputStreamReader(spoof.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
htmlText=htmlText + inputLine + "\n";
} catch (Exception e) {
e.printStackTrace();
} finally {
if (in != null)
in.close();
}
Log.d("getURL", "done");
return htmlText;
}
the Exeption is in this line:
in = new BufferedReader(new InputStreamReader(spoof.getInputStream()));
Thanks for any help