If i have some code such as input = new BufferedReader(new FileReader(args[0])); And the input file contain pairs of lines, how can I make it so only the first line from each line is imported? So in other words, every odd numbered line only?
Thanks
If i have some code such as input = new BufferedReader(new FileReader(args[0])); And the
Share
You might like to consider the use of
java.io.LineNumberReaderto make the filtering of odd lines (lineNo % 2 == 1) simpler. Or in an alternative approach, if you are using JDK7, you could use thejava.nio.files.Files.readAllLines()method and again filter the odd ones upon iteration.