【发布时间】:2012-12-25 13:54:02
【问题描述】:
我正在使用适用于 Android 的 MonoDevelop,希望获得一些帮助以从 Internet 下载文本文件并将其存储在字符串中。
这是我的代码:
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)
{
}
我收到以下错误:
无效的表达式术语'in';
能否请我帮忙以使此代码正常工作。如果有更简单的方法可以从 WWW 上下载文本文件并将内容保存到字符串中,请帮助我实现它。
提前致谢。
【问题讨论】:
标签: c# text download monodevelop inputstream