Hello guys I am writing multiple lines of details for a file and using array, Somehow when i run the program it always replace the last value stored in array not all details, using this code :
Scanner aca = new Scanner (new File ("C:\\Users\\User\\Documents\\aca.txt"));
int addAca;
addAca = aca.nextInt();
aca.close();
FileWriter fileinp_aca = new FileWriter ("C:\\Users\\User\\Documents\\aca.txt");
fileinp_aca.append("\n" +(addAca+1));
fileinp_aca.close();
PrintWriter bw_data = new PrintWriter (new FileWriter (data));
if ((addAca-1) < ROW && (addAca -1) >= 0){
int row = addAca - 1;
int col = 0;
for (int m=row; m<=50 ;) {
for (int n = col; n<9;n++) {
bw_data.print (details [m][n]);
details [row][col +0] = newStaff.get1();
details [row][col +1] = newStaff.get2();
details [row][col +2] = newStaff.get3();
details [row][col +3] = newStaff.get4();
details [row][col +4] = newStaff.get5();
details [row][col +5] = newStaff.get6();
details [row][col +6] = newStaff.get7();
details [row][col +7] = newStaff.get8();
details [row][col +8] = newStaff.get9();
a = details [row][col +0];
b = details [row][col +1];
c = details [row][col +2];
d = details [row][col +3];
e = details [row][col +4];
f = details [row][col +5];
g = details [row][col +6];
h = details [row][col +7];
i = details [row][col +8];
bw_data.print (a);
bw_data.append(System.getProperty(" "));
bw_data.print (b);
bw_data.append(System.getProperty(" "));
bw_data.print (c);
bw_data.append(System.getProperty(" "));
bw_data.print (d);
bw_data.append(System.getProperty(" "));
bw_data.print (e);
bw_data.append(System.getProperty(" "));
bw_data.print (f);
bw_data.append(System.getProperty(" "));
bw_data.print (g);
bw_data.append(System.getProperty(" "));
bw_data.print (h);
bw_data.append(System.getProperty(" "));
bw_data.print (i);
bw_data.append(System.getProperty(" "));
bw_data.close();
break;
}
break;
}
}
else
System.out.println ("Data full.");