みんな私は何かを理解する必要があります: \n は改行の先頭にありますか? その場合、RTL 文字を含むファイルを解析しようとしていて、それらは行の先頭にあるため、次のようになります。
- xxx xxxx、ABC DEFG、1、11、111、786
- xxx xxxx、ABC DEFG、1、11、111、786
- 等...
txt ファイル (資産からのアンドロイド) を解析するとき、前の行の整数に連結された次の行の最初の単語を取得し続けます。私はすべてを試しましたが、運がありません。
コード スニペットを次に示します。
InputStream is;
try {
is = new BufferedInputStream(getAssets().open(fileName));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
InputStream is = new BufferedInputStream(getAssets().open(fileName));
byte[] c = new byte[128];
byte[] d = null;
int readChars = 0;
int lineNumber = 0;
String line;
String[] paramLineArray = null;
int k;
while ((readChars = is.read(c)) != -1) {
for (int i = 0; i < readChars; i++) {
if (c[i] == '\n') {
lineNumber++;
line = new String(c);
k = 0;
StringTokenizer st = new StringTokenizer(line,",");
paramLineArray = new String[st.countTokens()];
while (st.hasMoreTokens()) {
// get next token and store it in the Line
paramLineArray[k] = st.nextToken();
k++;
}
}
}
publishProgress(((int) (1 / (float) lineNumber) * 100));
populateTables(paramLineArray, tblName, tblElements);
}
私が達成しようとしているのはこれです:
テキストファイルを非常に高速に1行ずつ解析して、DBに挿入される配列に...
何か案は???
私は何日もそれを続けてきたので、助けは大歓迎です(髪を失います:-()...
現在、私は InputStreamReader で動作するコードを持っていますが、非常に遅いです!!!!!
ありがとうございました。
ジェイドイェ。