import java.io.*;
class Ex117_IO
{
public static void main(String[] args)
{
//Ex117_IO.java
//학생 정보 관리
// - 이름, 나이, 연락처, 주소
// - ex117.dat
//DB -> DB 모델링, DB설계 [-> 정규화]
//홍길동|20|010-555-8888|서울시
try
{
BufferedReader reader =
new BufferedReader(new InputStreamReader(System.in));
System.out.print("이름 : ");
String name = reader.readLine();
System.out.print("나이 : ");
String age = reader.readLine();
System.out.print("연락처 : ");
String tel = reader.readLine();
System.out.print("주소 : ");
String addr = reader.readLine();
BufferedWriter writer =
new BufferedWriter(new FileWriter("ex117.dat"));
String item = String.format("%s|%s|%s|%s\n",
name,age,tel,addr);
writer.write(item);
writer.close();
System.out.println("학생 추가 완료!!");
}catch(Exception e) {
}
try
{
BufferedReader reader =
new BufferedReader(new FileReader("ex117.dat"));
String line = "";
while((line = reader.readLine()) != null) {
//홍길동|20|010-555-8888|서울시
//사람 수 만큼
String[] temp = line.split("\\|");
System.out.printf("%s\t%s\t%s\t%s\n",
temp[0],temp[1],temp[2], temp[3]);
}
reader.close();
}catch(Exception e) {
System.out.println("오류");
}
}//end main
}