Java : I/O

unchapterd·2021년 11월 1일
0

Java

목록 보기
16/19

I/O ( Input / Output )

  1. FileReader
  2. Scanner
  3. BufferedReader & Writer

FileReader

System.util.*;

Scanner

import java.util.Scanner;

public class ForTest {
  public static void main(String[] args) {
  	Scanner scan=new Scanner(System.in);
  }
}

System.io.*;

BufferedReader+InputStreamReader

import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class ForTest {
  public static void main(String[] args) throws IOException {
    BufferedReader scan=new BufferedReader(new InputStreamReader(System.in));
  }
}

BufferedWriter+OutputStreamWriter

import java.io.IOException;
import java.io.BufferedWrtier;
import java.io.InputStreamWriter;

public class ForTest{
  public static void main(String[] args) throws IOException {
    BufferedWriter pen=new BufferedWriter(new OutputStreamWriter(System.out));
  }
}

FileWriter

import java.io.FileWriter;
import java.io.IOException;
public class Main {
  static void main(String[] args) {
    try {
      FileWriter fw=new FileWriter("test.txt");
      System.out.println("파일 쓰기 준비 완료!");
    } catch (IOException ioe) {
      System.out.println("폴더 경로 이상");
    }
  }
}
profile
문제없는 기록

0개의 댓글