static void dataSave(String student[][]) {
/*
이름-나이-영어-수학
이름-나이-영어-수학
이름-나이-영어-수학
*/
int count = 0;
for (int i = 0; i < student.length; i++) {
if(!student[i][0].equals("")) { // student[i][0].equals("") == false
count++;
}
}
String saveData[] = new String[count];
for (int i = 0; i < saveData.length; i++) {
saveData[i] = student[i][0] + "-"
+ student[i][1] + "-"
+ student[i][2] + "-"
+ student[i][3];
}
for (int i = 0; i < saveData.length; i++) {
System.out.println(saveData[i]);
}
File file = new File("d:\\tmp\\student.txt");
try {
FileWriter fw = new FileWriter(file);
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter pw = new PrintWriter(bw);
for (int i = 0; i < saveData.length; i++) {
pw.println(saveData[i]);
}
pw.close();