Java 如何隔行读取文件?

现在有一个文件input.dat
请问如何把这个文件中的奇数行读入一个字符串数组,将文件中的偶数行读入另一个字符串数组?

public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.dat")),
"UTF-8"));
String lineTxt = null;
int a = 0;
ArrayList 奇数行 = new ArrayList<>();
ArrayList 偶数行 = new ArrayList<>();
while ((lineTxt = br.readLine()) != null) {
a++;
if(a%2==0){
偶数行.add(lineTxt);
}else {
奇数行.add(lineTxt);
}
}
br.close();
} catch (Exception e) {
System.err.println("read errors :" + e);
}
}

首先你知道怎么把文件读入数组吧?

int a=1; //代表行数
if(a%2==0){
    //行数为偶数  处理代码
}else{
    //行数为奇数  处理代码
}

int a=1; //代表行数
if(a%2==0){
//行数为偶数

}else{
//行数为奇数

}

3楼写的代码已经是很清晰的了,