I have a file that is set up like:
10 10
12 32
38 12
I need to put the lines in the even slots in one array and the lines in the odd slots in another array. I am new to java and I have no idea how to do this. I have been searching the internet for hours and have not found anything. Please help me! I will really appreciate it!
I am using a Buffered Reader to read in the file. I have already written a program that reads in the file and puts all the lines in an array, now I just need to know how to code it to separate the lines. So the lines 1,3,5,7,9 will be in one array and lines 2,4,6,8 will be in another.
Code that I have for putting them in one array:
private static final String FILE = "file.txt";
private static Point[] points;
public static void main(final String[] args){
try{
final BufferedReader br = new BufferedReader(new FileReader(new File(FILE)));
points = new Point[Integer.parseInt(br.readLine())];
int i = 0;
int xMax = 0;
int yMax = 0;
while(br.ready()){
final String[] split = br.readLine().split("\t");
final int x = Integer.parseInt(split[0]);
final int y = Integer.parseInt(split[1]);
xMax = Math.max(x, xMax);
yMax = Math.max(y, yMax);
points[i++] = new Point(x, y);
}
try