I have a text file contain a coordinate
100,20
240,100
23,45
I manage to read row and split it into and integer.
and get it to point x=100 ,y=20.
the problem is in the end i got a null
when i print in console show a null like this
100
20
240
100
23
45
null
null
my code to read row and then split is below
public String[] arrayData(String a) throws FileNotFoundException, IOException {
openFile(a);
int y = countRow(a);
String[] dataJ = new String[y];
z.useDelimiter("\n");
int i = 0;
while (z.hasNext()) {
dataJ[i] = z.next();
i++;
}
z.close();
return dataJ;
}
public Point[] splitArraytoPoint(String[] a) {
String[] arr;
String delimiter = ",";
int j = 0;
Point[] dataK = new Point[a.length];
for (int i = 0; i < a.length; i++) {
arr = a[i].split(delimiter);
for (int k = 0; k < 2; k++) {
//System.out.println(i + " " + k + " " + arr[k]);
if (k == 0) {
System.out.println(Integer.parseInt(arr[0].trim()));
dataK.x=Integer.parseInt(arr[0].trim());
}
if(k==1) {
System.out.println(Integer.parseInt(arr[1].trim()));
dataK.y=Integer.parseInt(arr[1].trim());
}
}
j++;
}
return dataK;
}
where is the problem....
help plz.