【发布时间】:2017-06-21 14:13:23
【问题描述】:
我正在编写一个安卓应用程序。我正在解析 txt 文件中的行并将每行中的数据插入 SQLite 数据库。但是插入过程恰好在 1000 个条目处停止。有超过 3000 个条目,但插入过程在 1000 处停止。出了什么问题?
编辑:这是代码:
try{
InputStream is = ctx.getAssets().open("feedtitlesandaddresses.txt");
InputStreamReader iz=new InputStreamReader(is);
BufferedReader br = new BufferedReader(iz);
ContentValues values = new ContentValues();
while((line=br.readLine())!=null) {
StringTokenizer stringTokenizer = new StringTokenizer(line, "<");
String firstNumber="";
String strfinal="";
**//code which gives values to strfinal and firstNumber excluded
values.put(KEY_NAME, firstNumber); // Contact Name
values.put(KEY_PH_NO,strfinal); // Contact Phone
// Inserting Row
db.insert(TABLE_CONTACTS, null, values);}
}catch(Exception e){Log.d("yeah error is"+e,"twitch12");}
【问题讨论】:
-
@RaghavSood:已添加..
-
android的readLine()方法如何处理txt文件中只包含回车或换行的一行?那行 = "" 还是 null?
-
@tim 我假设您在谈论文件结尾。它是 null 而不是 ""。
-
我的意思是行尾。文本文件是否有可能包含被 readLine() 方法解析为 NULL 的“空白”行(除了行尾字符)?
-
@tim 不,该行没有问题,我从该行上方删除了 2 行并运行了应用程序,现在第 1000 个条目是问题行下方 2 行的那个,所以这条线没有问题..