자바 filePutContents()

Jmnote bot (토론 | 기여)님의 2020년 11월 2일 (월) 02:49 판 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

자바 filePutContents()
BufferedWriter bw = new BufferedWriter( new FileWriter( "test.txt" ) );
bw.write( "John Smith" );
bw.close();
PrintWriter pw = new PrintWriter( "test.txt" );
pw.println( "John Smith" );
pw.close();
PrintWriter pw = new PrintWriter( new FileWriter( "test.txt" ) );
pw.println( "John Smith" );
pw.close();

2 함수[ | ]

public static void filePutContents(String filename, String data) {
	filePutContents(filename, data, false);
}
public static void filePutContents(String filename, String data, boolean append) {
	try {
		BufferedWriter bw = new BufferedWriter( new FileWriter( filename, append ) );
		bw.write( data );
		bw.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
}

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}