import java.io.*;
class Ex116_FileStream
{
public static void main(String[] args)
{
//Ex116_FileStream
m1();
m2();
}
//파일 쓰기
//BufferedWriter
public static void m1() {
try
{
BufferedWriter writer =
new BufferedWriter(new FileWriter("D:\\student.dat"));
writer.write("홍길동\r\n");
writer.write("아무게");
writer.newLine();
writer.write("하하하\r\n");
writer.close();
System.out.println("쓰기완료");
}catch(Exception e) {
}
}//end m1()
//파일 읽기
//BufferedReader
public static void m2() {
try
{
BufferedReader reader =
new BufferedReader(new FileReader("D:\\student.dat"));
String txt = "";
while((txt = reader.readLine()) != null)
{
System.out.println(txt);
}
reader.close();
}catch(Exception e) {
System.out.println("오류");
}
}//end m2()
}