static String[][] dataLoad() {
String str[] = null;
// 파일 읽기
File file = new File("d:\\tmp\\student.txt");
try {
FileReader fr = new FileReader(file);
// 데이터 갯수
int count = 0;
String s;
BufferedReader br = new BufferedReader(fr);
while( (s = br.readLine()) != null ) {
count++;
}
br.close();
// 할당
str = new String[count];
// 데이터를 저장
int i = 0;
fr = new FileReader(file);
br = new BufferedReader(fr);
while( (s = br.readLine()) != null ) {
str[i] = s;
i++;
}
// student[][] return
} catch (Exception e) {
// TODO
e.printStackTrace();
}
/*
for (int i = 0; i < str.length; i++) {
System.out.println(str[i]);
}
*/
// student[][] <- str[]
String student[][] = new String[20][4];
for (int i = 0; i < student.length; i++) {
for (int j = 0; j < student[i].length; j++) {
student[i][j] = "";
}
}
for (int i = 0; i < str.length; i++) {
String s = str[i]; // 홍길동-24-90-100
String split[] = s.split("-");
student[i][0] = split[0];
student[i][1] = split[1];
student[i][2] = split[2];
student[i][3] = split[3];
}
return student;
}