import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;

public class Ex008_Encoding {

	public static void main(String[] args) {
		// MS949(euc-kr 유사) 데이터를 UTF-8 형식의 파일로 저장하기
		int data;
		String pathname = "test.txt";
		
		// 파일에 내용을 문자 출력 스트림. 인코딩은 UTF-8
		try (Writer wt = new OutputStreamWriter(new FileOutputStream(pathname), "UTF-8") ){
			// 바이트 스트림을 문자 스트림으로 바꿈
			// byte 스트림을 문자 스트림으로. 인코딩은 MS949
			Reader rd = new InputStreamReader(System.in, "MS949");
			
			// Reader rd = new InputStreamReader(System.in); // 시스템에 설정된 기본 인코딩

			System.out.println("입력[종료:ctrl+z]...");
			while( (data = rd.read()) != -1) {
				wt.write(data);
			}
			wt.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}

문자 스트림을 다루기 때문에 내용을 보낼 때 Writer, 내용을 받을 때 Reader 를 사용한다.

여기서는 키보드를 통해 입력받은 것을 test.txt로 저장한다.

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;

public class Ex009_Encoding {

	public static void main(String[] args) {
		// UTF-8 파일을 MS949 파일로 복사하기
		String source = "test.txt";
		String dest = "ex.txt";
		
		int data;
		try(Reader rd = new InputStreamReader(new FileInputStream(source), "UTF-8");
			Writer wt = new OutputStreamWriter(new FileOutputStream(dest), "MS949")	
			) {
			
			while( (data = rd.read()) != -1) {
				wt.write(data);
			}
			wt.flush();
			
			System.out.println("변환 저장 완료...");
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

위에서 test.txt 저장한 것을 MS949로 변환시켜준다.

import java.io.BufferedReader;
import java.io.File;
// import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Ex003_Cat { // 텍스트파일 안에 들어있는 내용을 확인하는 리눅스 명령어
	// ls 파일목록 확인
	public static void main(String[] args) {
		// 텍스트 파일 내용 읽기
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String pathname;
		String s;
		
		BufferedReader fbr = null;
		
		try {
			System.out.print("파일명 ? ");
			pathname = br.readLine();
			
			File f = new File(pathname);

/*			if( ! f.exists()) {
				System.out.println("파일이 존재하지 않습니다.");
				System.exit(0);
			}
*/
			// byte 스트림 -> InputStreamReader -> 문자 스트림
			// fbr = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
			// fbr = new BufferedReader(new InputStreamReader(new FileInputStream(pathname)));
			// 바이트 스트림 -> 문자로 고침
			// fbr = new BufferedReader(new FileReader(pathname));
			fbr = new BufferedReader(new FileReader(f));
			// Reader 는 한 문자를 입력 받을 수 있다.
			while( (s = fbr.readLine()) != null) {
				System.out.println(s);
			}
			
		} catch (FileNotFoundException e) {
			System.out.println("파일이 존재하지 않습니다.");
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if(fbr != null) {
				try {
					fbr.close();
				} catch (Exception e2) {
				}
			}
		}
		
	}

}

텍스트 파일안에 있는 문자들을 읽어서 화면에 출력해준다.

파일 정보

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Ex001_File {

	public static void main(String[] args) {
		String appDir = System.getProperty("user.dir");
		// System.out.println("현 작업경로 : " + appDir);

		String pathname = appDir + File.separator + "user.txt";
		// File.separator : 윈도우즈는 \, Mac이나 리눅스는 /
		// System.out.println(pathname);

		File f = new File(pathname);
		// exists() : 폴더 또는 파일이 존재하면 true, 없으면 false를 반환
		if (!f.exists()) {
			System.out.println(pathname + " 파일은 존재하지 않습니다.");
			System.exit(0);

		}

		try {
			System.out.println("파일정보...");
			System.out.println("파일명 : " + f.getName()); // 파일명.확장자
			System.out.println("경로명 : " + f.getPath()); // c:\폴더\파일명.확장자
			System.out.println("절대경로명 : " + f.getAbsolutePath()); // c:\폴더\파일명.확장자
			System.out.println("표준경로명 : " + f.getCanonicalPath()); // c:\폴더\파일명.확장자
			
			System.out.println("부모경로 : "+f.getParent()); // c:\폴더
			System.out.println("파일길이(long형, 단위:byte) : " + f.length());
			// f.lastModified() : 1970.1.1부터 파일생성일까지를 ms단위로 환상하여 반환
			System.out.println("파일 생성일자 : " + new Date(f.lastModified()));
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
			String s = sdf.format(new Date(f.lastModified()));
			System.out.println("파일생성일 : " + s);
			System.out.println("읽기 속성 : "+f.canRead());
			System.out.println("쓰기 속성 : "+f.canWrite());
			
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

System.getProperty("user.dir");으로 현재 작업경로를 알 수 있다.

File.separator : Windows는 \, Mac이나 Linux / 을 나타낸다.

 

f.exists() : 폴더 또는 파일이 존재하면 true, 없으면 false를 반환

System.exit(0) : 프로그램 종료

 

File클래스를 통해 파일명, 경로, 절대경로, 표준경로, 파일길이, 생성일자 ... 등을 알 수 있다.

 


파일 삭제 (1) - 한 개만 삭제

import java.io.File;

public class Ex002_FileDelete {

	public static void main(String[] args) {
		String appDir = System.getProperty("user.dir"); // 현재 작업 경로
		String pathname = appDir + File.separator + "test.txt";

		File f = new File(pathname);

		if (!f.exists()) {
			System.out.println(pathname + "파일이 존재하지 않습니다.");
			System.exit(0);
		}

		boolean b = f.delete();
		// 파일 또는 디렉토리 삭제
		// 한번에 하나의 파일 또는 디렉토리만 삭제 가능
		// 디렉토리는 비어 있어야 삭제가 가능
		if (b) {
			System.out.println("파일이 삭제 되었습니다.");
		} else {
			System.out.println("파일 삭제가 실패 했습니다.");
		}

	}

}

f.delete(); 메소드

- 파일 또는 디렉토리를 삭제한다.

- 한번에 하나의 파일 또는 디렉토리만 삭제가 가능하다.

- 디렉토리는 비어 있어야 삭제가 가능하다.


파일 삭제(2) - 해당 경로에 있는 모든 파일 삭제

import java.io.File;

public class Ex007_FileRemove {
	public static void main(String[] args) {
		String pathname = "C:"+File.separator + "ex";
		FileManager fm = new FileManager();
		
		fm.removeDir(pathname);
		
		System.out.println("디렉토리 또는 파일 삭제 완료...");
	}
}

class FileManager {
	/**
	 * 파일 또는 폴더 삭제 (하위 폴더 및 모든 파일도 제거 되므로 조심해라...)
	 * @param pathname 삭제할 폴더 또는 파일
	 * @return		   폴더 또는 파일 삭제 여부
	 */
	public boolean removeDir(String pathname) {
		boolean b = false;
		
		try {
			File f = new File(pathname); 
			if(f.isDirectory()) { // 폴더이면 속으로 들어가라
				removeSubDir(pathname);
			}
			
			b = f.delete(); // 폴더가 아니면 삭제
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return b;
	}
	
	private void removeSubDir(String pathname) {
		File[] ff = new File(pathname).listFiles();
		try {
			if(ff.length == 0) // 자식이 없는 경우
				return;
			
			for(File f : ff) {
				if(f.isDirectory()) { // 폴더면 또 안으로 들어가기
					removeSubDir(f.getPath()); // 재귀 호출
				}
				f.delete();
			}
		} catch (Exception e) {
		}
	}
	
}

f.delete() 폴더가 아니면 삭제하고 자식이 없는 디렉토리일시에도 삭제한다.

 

디렉토리 일시 안으로 들어가서 파일들을 하나씩 다 삭제하는데, 다시 또 디렉토리면 재귀 호출을 통해 해당 경로에 있는 디렉토리 안으로 들어가서 또 파일을 하나씩 다 삭제한다.


파일 리스트

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Ex004_FileList {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;
		
		try {
			System.out.print("경로 ? ");
			s = br.readLine();
			dirList(s);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void dirList(String pathname) {
		// 폴더에 존재하는 폴더 또는 파일 리스트 확인하기
		File file = new File(pathname);
		
		if ( ! file.exists()) {
			System.out.println("디렉토리가 존재하지 않습니다.");
			return;
		}
		
		if(! file.isDirectory()) {
			System.out.println("디렉토리가 아닙니다.");
			return;
		}
		
		File [] ff = file.listFiles();
			// 폴더에 존재하는 모든 폴더 또는 파일에 대한 File 객체를 반환
		try {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
			String s;
			for(File f : ff) {
				s = sdf.format(new Date(f.lastModified()));
				if(f.isFile()) {
					System.out.print(f.getName()+"\t");
					System.out.print(s+"\t");
					System.out.println(f.length()+"bytes");
				} else if(file.isDirectory()) {
					System.out.println("["+f.getName()+"]...");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		
		
	}

file.exists() 입력한 경로에 파일/디렉토리가 존재하지 않으면 false를 반환한다.

file.isDirectory() 입력한 경로가 디렉토리면 true, 아니면 false를 반환한다.

file.listFiles() 입력한 경로에 존재하는 모든 파일, 디렉토리를 파일 배열로 반환한다.

 

파일은 파일명, 생성날짜, 파일길이를 출력하고

디렉토리는  [ ] 대괄호로 출력한다.


파일 만들기

import java.io.File;

public class Ex005_FileMakeDir {

	public static void main(String[] args) {
		String pathname = "c:"+File.separator+"ex"+File.separator+"test";
		
		try {
			File f = new File(pathname);
			
			if(! f.exists()) {
				f.mkdirs(); // 상위 폴더가 존재하지 않으면 상위 폴더도 생성함
				// f.mkdir(); // 상위 폴더가 존재하지 않으면 폴더를 생성하지 않음
				System.out.println("디렉토리를 생성했습니다.");
			} else {
				System.out.println("존재하는 디렉토리입니다.");
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

f.mkdirs() 상위 폴더가 존재하지 않으면 상위 폴더도 생성한다. 즉 ex가 없으면 ex도 만들고 test도 만든다.

f.mkdir() 상위 폴더가 존재하지 않으면 폴더를 생성하지 않음. 즉, ex가 없으면 test가 만들어지지 않는다.


파일 이름 변경하기

import java.io.File;
import java.util.Calendar;

public class Ex006_FileRename {

	public static void main(String[] args) {
		String appDir = System.getProperty("user.dir");
		String pathname = appDir + File.separator + "ex.txt";
		
		File f = new File(pathname);
		if(! f.exists()) {
			System.out.println(pathname+" - 존재하지 않음...");
			System.exit(0);
		}
		
		// 확장자(.txt)
		String fileExt = pathname.substring(pathname.lastIndexOf("."));
		
		Calendar cal = Calendar.getInstance(); // 현재 시스템의 날짜/시간을 가지고 있음
		String newName = String.format("%1$tY%1$tm%1$td%1$tH%1$tM%1$ts",  cal);
		// 1$ 는 첫번째 변수, 
		newName +=System.nanoTime() + fileExt;
		// System.out.println(newName);
		
		try {
			String newFilename = appDir + File.separator + newName ;
			File dest = new File(newFilename);
			
			// 파일 또는 디렉토리 이름 변경
			f.renameTo(dest);
			System.out.println("파일 이름 변경 완료...");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

}

f.renameto(File dest); 파일 또는 디렉토리 이름을 변경해준다.

 

확장자가 변경되면 안되므로 substring을 통해 마지막 . 뒤에는 따로 저장해 놓는다.

그리고 주고 싶은 이름을 설정하고 확장자를 다시 붙이면 된다.

 


 

FileOutputStream

- 데이터를 파일 시스템의 파일에 바이트 스트림으로 저장하기 위해 사용된다.

- OutputStream 클래스의 하위 클래스

- 기본적으로 파일이 없으면 생성하고, 이미 존재하면 그 파일에 덮어씀으로 기존 내용은 사라진다.

import java.io.FileOutputStream;

public class Ex17_FileOutputStream {

	public static void main(String[] args) {
		String pathname = "test.txt";
		FileOutputStream fos = null;
		int data;
		
		try {
			// fos = new FileOutputStream(pathname);
				// 없으면 만들고, 파일이 존재하면 지우고 새로 만든다.
			
			fos = new FileOutputStream(pathname, true);
				// 없으면 만들고, 파일이 존재하면 기존 파일을 지우지 않고 추가(append)한다.
			
			System.out.println("내용 입력[종료:Ctrl+z]");
			while( (data = System.in.read()) != -1) {
				fos.write(data);
			}
			fos.flush();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if(fos != null) {
				try {
					fos.close();
				} catch (Exception e2) {
				}
			}
		}

	}

}

FileOutputStream(String name); 

name이 없으면 만들고, 파일이 존재하면 지우고 새로 만든다.

FileOutputStream(String name, ture); 

name이 없으면 만들고, 파일이 존재하면 기존 파일을 지우지 않고 추가.

import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

public class Ex15_FileWriter {

	public static void main(String[] args) {
		String pathname = "test.txt";
		int data;
		
		// OutputStream(byte 스트림) => OutputStreamWriter => Writer(문자 출력 스트림) 변환		
		try(FileWriter fw = new FileWriter(pathname)) {
			// 파일출력 문자 스트림
				// text 파일만 저장할 수 있으며, 이미지, 동영상, 2진파일 등을 저장 불가능하다.
			
			System.out.println("문자열 입력:종료[ctrl+z]");
			
			Reader rd = new InputStreamReader(System.in);
			while ( (data = rd.read()) != -1 ) {
				fw.write(data);
			}
			fw.flush();
			
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}

Writer 은 문자 출력 스트림을 처리하는 클래스이다. FileWriter도 문자를 다루므로 text 파일만 저장할 수 있다.

 

import java.io.FileReader;
import java.io.OutputStreamWriter;
import java.io.Writer;

public class Ex16_FileReader {

	public static void main(String[] args) {
		String pathname = "test.txt";
		int data;
		
		try(FileReader fr = new FileReader(pathname)) {
			// 파일 입력 문자 스트림. text 파일만 읽을 수 있음.
			// 이미지, 이진 파일 등은 입력 하면 안됨.
			
			Writer wt = new OutputStreamWriter(System.out);
			
			System.out.println("파일 내용...");
			while( (data = fr.read()) != -1){
				wt.write(data);
			}
			wt.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

Reader은 문자 스트림을 다루는 클래스이다. FileWriter도 문자를 다루므로 text 파일만 읽을 수 있다.

자바로 파일을 복사하는 프로그램을 코딩해보자.

 

1) 잘못된 예

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class FileCopyEx1 {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// 키보드로 입력을 받는다.
		String source, dest;
		
		FileOutputStream fos = null;
		FileInputStream fis = null;
		
		try {
			System.out.print("복사할 원본 파일명 ? ");
			source = br.readLine();
			
			System.out.print("복사시킬 대상 파일명 ? ");
			dest = br.readLine();
			
			fis = new FileInputStream(source);
			fos = new FileOutputStream(dest);
			
			// 잘못 코딩한 예 - 서울에서 부산을 걸어서 가는 꼴
			int data;
			while( (data = fis.read()) != -1) {
				fos.write(data);
			}
			fos.flush();
			System.out.println("파일 복사 완료...");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if ( fis != null) {
				try {
					fis.close();
				} catch (Exception e2) {
				}
			}
			if ( fos != null) {
				try {
					fos.close();
				} catch (Exception e2) {
				}
			}
		}
		
		
	}

}

 

2) 효율적인 방식

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class FileCopyEx2 {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// 키보드로 입력을 받는다.
		String source, dest;
		
		FileOutputStream fos = null;
		FileInputStream fis = null;
		
		byte[] b = new byte[4096];
		int len;
		
		try {
			System.out.println("파일 복사...");
			
			System.out.print("복사할 원본 파일명 ? ");
			source = br.readLine();
			
			System.out.print("복사시킬 대상 파일명 ? ");
			dest = br.readLine();
			
			fis = new FileInputStream(source);
			fos = new FileOutputStream(dest);
			
			long s = System.currentTimeMillis();
			// len = fis.read(b) => 최대 바이트배열 b길이 만큼 읽어 b에 저장하고
			// 실제로 읽어 들인 byte수를 반환
			while( (len = fis.read(b)) != -1) {
				fos.write(b, 0, len); // b배열의 0번째 인덱스부터 len개 저장
			}
			fos.flush();
			long e = System.currentTimeMillis();
			
			System.out.println("파일 복사 완료..." + (e-s)+"ms");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if ( fis != null) {
				try {
					fis.close();
				} catch (Exception e2) {
				}
			}
			if ( fos != null) {
				try {
					fos.close();
				} catch (Exception e2) {
				}
			}
		}
		
		
	}

}

ABCDEF 가 파일에 있어서 이 문자들을 읽어서 다른 파일에 붙일때, A를 읽으면 다시 A를 읽지 않는다. 

읽은 것은 다시 읽지 않는다! 그래서 배열에 인덱스 없이도 알아서 다 들어갔다가 다음 배열에 또 들어가고 그렇게 되는 것이다.

FileInputStream 클래스

- 파일 시스템의 파일로 부터 파일 내용을 바이트 스트림으로 읽어 들이기 위해 사용된다.

- InputStream 클래스의 하위 클래스

- 파일이 존재하지 않으면 FileNotFoundException 예외가 발생

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Ex13_FileInputStream {

	public static void main(String[] args) {
		String pathname = "test2.txt";
		int data;
		FileInputStream fis = null;

		try {
			fis = new FileInputStream(pathname);
				// FileInputStream : 파일 입력 byte 스트림
				// 만약 파일이 존재하지 않으면 fileNotFoundException 발생
			
			// FileNotFoundException < IOException < Exception
			System.out.println(pathname+" 파일 내용...");
			
			while( (data = fis.read()) != -1) {
				// 파일에서 읽은 내용을 화면에 출력
				System.out.write(data);
			}
			System.out.flush();
		} catch (FileNotFoundException e) {
			// 파일이 존재하지 않는 경우
			// e.printStackTrace();
			System.out.println(pathname + "는/은 존재하지 않는 파일 입니다.");
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if(fis != null) {
				try {
					fis.close();
				} catch (Exception e2) {
				}
			}
		}
	}

}

위와 같은 의미

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Ex14_FileInputStream {
	public static void main(String[] args) {
		String pathname = "text.txt";
		int data;
		
		try(FileInputStream fis = new FileInputStream(pathname)) {
			System.out.println(pathname + "파일 내용...");
			while ( (data = fis.read()) != -1) {
				System.out.write(data);
			}
			System.out.flush();
		} catch (FileNotFoundException e) {
			System.out.println(pathname+"은/는 존재하지 않는 파일 입니다.");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

FileInputStream(String name) 주어진 이름의 파일을 바이트 스트림으로 읽기 위한 FileInputStream 객체를 생성하는 메소드.

2021.08.24 - [쌍용강북교육센터/8월] - 0823_Java : FileOutStream 클래스 에서 저장한 파일을 읽어와 보았다.

FileOutStream 클래스

- 데이터를 파일 시스템의 파일에 바이트 스트림으로 저장하기 위해 사용된다.

- OutputStream(바이트 스트림) 클래스의 하위 클래스

- 기본적으로 파일이 없으면 생성하고, 이미 존재하면 그 파일에 덮어 씀으로 기존 내용은 사라진다.

 

import java.io.FileOutputStream;
import java.io.IOException;

public class Ex11_FileOutputStream {

	public static void main(String[] args) {
		String pathname = "test.txt";
		// 파일에 내용을 저장하는 byte 스트림
		FileOutputStream fos = null; // 메모리할당을 받지 않음.
		// 쓰레기를 가지고 있음.
		// 초기화되어있지 않아서. ex; int a; 
		int data;
		
		try { // 이 블록은 무조건 실행하는 것은 아님
			fos = new FileOutputStream(pathname); // 메모리할당받음
				// 해당 파일이 없으면 생성하고, 존재하면 삭제하고 만듦.
			System.out.println("문자열 입력[Ctrl+Z:종료]");
			while( (data = System.in.read()) != -1) {
				fos.write(data);
			}
			fos.flush();
			System.out.println("파일 저장 완료...");
			
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if(fos != null) { // 메모리할당되어있으면 닫아야함.
				try {
					fos.close(); // 리소스를 닫아주어야 에러가 생기지 않음.
				} catch (Exception e2) {
				}
			}
		}
		
	}

}

위와 같은 의미

import java.io.FileOutputStream;
import java.io.IOException;

public class Ex12_FileOutputStream {

	public static void main(String[] args) {
		String pathname = "test.txt";
		int data;
		
		// JDK 7.0부터 가능 자동 close
		try (FileOutputStream fos = new FileOutputStream(pathname)) {
			System.out.println("문자열 입력[종료:ctrl+z]");
			
			while( (data = System.in.read()) != -1) {
				fos.write(data);
			}
			fos.flush();
			System.out.println("파일 저장 완료...");
		} catch (IOException e) {
			// ctrl+shift+o : 자동 import
			e.printStackTrace();
		}

	}

}

try( 리소스 객체 생성) 하게 되면 자동으로 close 해주기 때문에 따로 finally 에서 문자열입력을 받았으면 (객체가 생성되었으면) 닫는 부분의 코딩을 안해도된다.

키보드로 입력한 값을 1byte씩 읽고 1byte씩 파일에 넣기 때문에 문자가 잘 들어가진다.

 

FileOutputStream(String name) 주어진 이름의 파일을 바이트 스트림으로 쓰기 위한 FileOutputStream객체를 생성한다. 

 

+ Recent posts