我想跳过文件的第一行和最后一行,并将剩余的信息插入到ArrayList中。这里是我有这样的农场插入文件中的所有元素到一个ArrayList。如何将文件中的元素从特定位置插入到ArrayList中?
CodonSequence cs = new CodonSequence();
try {
Scanner scanner = new Scanner(new File("testSequence.txt"));
while (scanner.hasNextLine()) {
cs.addNucleotide(scanner.nextLine());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}