프로그래밍/JAVA

2013-08-18 File 클래스 - Write

족제비상 2013. 8. 18. 15:04
// File Name : Sample01.java
// Make File : abc.txt

public class Sample01
{
	public static void main (String[] args) 
	{
		// Write File
		File file = new File("C:\\Users\\RyuDongYup\\workspace\\JavaSample03\\abc.txt");
		try
		{
			FileOutputStream fos = new FileOutputStream(FileDescriptor.out);
			FileOutputStream fos1 = new FileOutputStream(file);
			byte[] data = {66, 68, 70, 72, (byte)'!'};    // 파일에 입력할 텍스트
			fos.write(data);
			fos1.write(data);
		}catch(FileNotFoundException fnfe)
		{
			System.out.println("파일을 못찾겠다.");
			System.exit(1);
		}catch(IOException io)
		{
			System.out.println("파일 입출력 에러!!");
			System.exit(1);
		}
		System.out.println("실행끝...!");
	}
}

'프로그래밍 > JAVA' 카테고리의 다른 글

2013-08-23 List 클래스  (2) 2013.08.23
2013-08-18 Frame 클래스 (자바 UI 만들기)  (0) 2013.08.18
2013-08-18 abstract 클래스  (1) 2013.08.18