[Java] 파일 입출력
·
Language/Java
파일 쓰기 import java.io.FileOutputStream; import java.io.IOException; public class Sample { public static void main(String[] args) throws IOException { FileOutputStream output = new FileOutputStream("c:/out.txt"); output.close(); } } 위 예제를 실행해 보면 c:/ 디렉토리 바로 밑에 새로운 파일(out.txt)이 하나 생성되는 것을 확인할 수 있을 것이다. ※ 맥(Mac)이나 유닉스에서 실행할 경우 c:/ 디렉터리가 없으므로 디렉터리명을 적절하게 변경하여 실행하도록 한다. 파일을 생성하기 위해 FileOutputStream 클래..