I request a text file from a server. The url does not end in some_file.txt, because the file is created dynamically per the request (not sure if that is even relevant). When I use the code below, I do not read in the text (though I do read in html, if pointed to a url that has html).
String text = "RESULTS:\n";
try {
String urlString =
"http://appdata.mysite.com/httpauth/" +
"hub/DAR_param1_RTQB?" +
"method=query&list=param2";
// Create a URL
URL url = new URL(urlString);
// Read all the text returned by the server
in = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line = in.readLine()) != null) {
text = text + line;
}
} catch (MalformedURLException e) {
} catch (IOException e) {
} catch (Exception e) {
} finally {
if ( in != null ) {
try {
in.close();
} catch (IOException e) {
Log.e(TAG, "Exception trying to close BufferedReader");
}
}
}
return text;
This returns only "RESULTS:", but none of the text. What am I missing?
Edit: Here is an example of the file. This is displayed in a browser if the url is pasted into the address bar:
20120120_1734
20120120_1725
20120120_1715
20120120_1705
20120120_1655