約行以上の大きCSV
なTSV
(タブ区切りの)ファイルを読み込もうとしています。今、私はを含む行1000000
を読み込もうとしましたが、それは私に。をスローします。行のある小さなファイルで動作します。だから私は巨大なファイルの読み取りをサポートするものが他にあるかどうか疑問に思いました。あなたはなにか考えはありますか?TSV
~2500000
opencsv
java.lang.NullPointerException
TSV
~250000
Libraries
CSV
TSV
私のコードに興味のある人は誰でも(私はそれを短くしているので、Try-Catch
明らかに無効です):
InputStreamReader in = null;
CSVReader reader = null;
try {
in = this.replaceBackSlashes();
reader = new CSVReader(in, this.seperator, '\"', this.offset);
ret = reader.readAll();
} finally {
try {
reader.close();
}
}
編集:これは私が:を構築する方法InputStreamReader
です
private InputStreamReader replaceBackSlashes() throws Exception {
FileInputStream fis = null;
Scanner in = null;
try {
fis = new FileInputStream(this.csvFile);
in = new Scanner(fis, this.encoding);
ByteArrayOutputStream out = new ByteArrayOutputStream();
while (in.hasNext()) {
String nextLine = in.nextLine().replace("\\", "/");
// nextLine = nextLine.replaceAll(" ", "");
nextLine = nextLine.replaceAll("'", "");
out.write(nextLine.getBytes());
out.write("\n".getBytes());
}
return new InputStreamReader(new ByteArrayInputStream(out.toByteArray()));
} catch (Exception e) {
in.close();
fis.close();
this.logger.error("Problem at replaceBackSlashes", e);
}
throw new Exception();
}