ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • JAVA_File
    JAVA 2020. 9. 4. 17:40
    반응형

    FileOutputStream을 이용한 파일 생성 및 쓰기

    public static void main(String[] args) throws IOException {
            FileOutputStream out = new FileOutputStream("d:/out.txt");
            for(int i=1; i<6;i++){
                String texts = i + "번 라인\n";
                out.write(texts.getBytes());
            }
            out.close();
        }

    FileWriter을 이용한 파일 생성 및 쓰기

    public static void main(String[] args) throws IOException {
            FileWriter out = new FileWriter("d:/out.txt");
            for(int i=1; i<6;i++){
                String texts = i + "번 라인\n";
                out.write(texts);
            }
            out.close();
        }

    PrintWriter을 이용한 파일 생성 및 쓰기

    public static void main(String[] args) throws IOException {
            PrintWriter out = new PrintWriter("d:/out.txt");
            for(int i=1; i<6;i++){
                String texts = i + "번 라인";
                out.println(texts);
            }
            out.close();
        }
    반응형

    'JAVA' 카테고리의 다른 글

    JAVA_Network  (0) 2020.09.03
    JAVA_GUI  (0) 2020.09.03
    JAVA_Parallel Operation  (0) 2020.09.03
    JAVA_Stream  (0) 2020.09.03
    JAVA_Collection  (0) 2020.09.03

    댓글

Designed by Tistory.