【发布时间】:2012-02-05 00:24:40
【问题描述】:
我在使用 bufferedReader 读取文件时遇到问题...我正在尝试读取每个单词都在换行符上的字典文件。它适用于我拥有的一个文件,但是当我尝试添加一个更大的 wordlist 文件时启用 wordlist,然后在第一次读取时:'while ((currentLine=br.readLine()) != null) '它会导致异常,没有描述...请帮忙!
try
{
InputStream is = this.getResources().openRawResource(R.raw.enable1);
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String currentLine=null;
while ((currentLine=br.readLine()) != null)
{
dictionaryList.add(currentLine);
}
br.close();
}
catch (Exception e)
{
//error here
}
*看起来文件大小限制为 1048576 字节......否则它会崩溃。
【问题讨论】:
-
异常被您拥有的
catch块停止。您只是没有在catch块内打印任何内容。尝试添加e.printStackTrace() -
谢谢,但我发现了超过 1048576 字节的新词表的问题,所以它导致了 io 异常...我将按字长将词表拆分为文件...应该让它更快地加载我正在做的事情!
标签: java android file-io dictionary bufferedreader