Android 应用程序中的 IOException
我刚刚开始进行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也有同样的问题。问题似乎是您只能读取最大 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