Android 应用程序中的 IOException

发布于 2024-09-13 07:28:01 字数 501 浏览 5 评论 0原文

我刚刚开始进行 Android 开发,并在 Android 应用程序中遇到一个问题。

当应用程序尝试从文件(原始资源)读取数据时,它会在 readLine() 函数上抛出 IOException。代码如下:

final Resources resources = m_ApplicationContext.getResources();
InputStream inputStream = resources.openRawResource(R.raw.datafile);
BufferedReader reader = new BufferedReader(new InputStreamReader(
   inputStream));

try {
 String line;
 while ((line = reader.readLine()) != null) {

reader.readLine() 函数抛出异常。我是否需要提及任何类型的附加权限来读取该文件?

提前致谢。

I have just started with Android development, and facing one issue in the android application.

When application tries to read the data from file (raw resources), it throws IOException on readLine() function. code is as below:

final Resources resources = m_ApplicationContext.getResources();
InputStream inputStream = resources.openRawResource(R.raw.datafile);
BufferedReader reader = new BufferedReader(new InputStreamReader(
   inputStream));

try {
 String line;
 while ((line = reader.readLine()) != null) {

the reader.readLine() function is throwing the exception. Do I need to mention any kind of additional permission for reading the file ?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神魇的王 2024-09-20 07:28:01

我也有同样的问题。问题似乎是您只能读取最大 1MB 的文件,

请参阅此处
http://groups.google.com/group/android-developers/browse_thread /线程/e3765c112d112f24

I have had the same issue. The problem seems to be that you can only read files with up to 1MB

see here
http://groups.google.com/group/android-developers/browse_thread/thread/e3765c112d112f24

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文