txtファイルを読み込もうとしています。txtファイルには次の行が含まれています。
First Line
Second Line
Third Line
.
.
.
今、私は次のコードを使用しています
InputStream is = null;
try {
is = getResources().getAssets().open("myFile.txt");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ArrayList<String> arrayOfLines = new ArrayList<String>();
Reader reader;
//char[] buffer = new char[2048];
try {
Reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
int n;
while ((n = reader.read()) != -1) {
}
}catch (Exception e) {
e.printStackTrace();
}
私の質問は、各行をarrayListに格納するにはどうすればよいかということです。多くの場合、チェックを使用する必要があり"/n"
ますが、その方法。