I am using MonoDevelop for Android and would like some help to download a text file off the internet and to store it in a string.
Here is my code:
try
{
URL url = new URL("mysite.com/thefile.txt");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String str;
while ((str = in.readLine()) != null)
{
// str is one line of text; readLine() strips the newline character(s)
}
in.close();
}
catch (MalformedURLException e)
{
} catch (IOException e)
{
}
I am getting the following error:
Invalid expression term 'in';
May I please have some help to get this code working. If there is an easier way to download a text file off the WWW and save the contents into a string, may I please have some help to implement it.
Thanks in advance.