728x90

 

문자 기반 스트림

FileWriter/FileReader 클래스

 

메소드 

write,append,close

import java.io.FileReader;
import static java.util.Collections.*;


import java.io.FileWriter;
import java.io.IOException;
public class practice_everyday08 {
	public static void main(String[] args) throws IOException {
		
		// 문자 기반 스트림
		// FileReader
		// FileWriter
		
		FileWriter fw = new FileWriter("D:\\file\\file2\\first.txt");
		fw.write("initiate\n");
		fw.append("2\n");
		char[] cArray = {'c','h','e','e','r'};
		char[] sArray = {'u','p'};
		fw.write(cArray);
		fw.write(sArray);
		fw.close();
		
		FileReader fr = new FileReader("D:\\file\\file2\\first.txt");
		int i;
		while((i=fr.read()) != -1) {
			System.out.print((char)i);
		}
		fr.close();
		
	}	
}

 

728x90
반응형

+ Recent posts