1. 스트림(Stream)
  (1) 정의 : 데이터의 흐름
  (2) 흐름도
       Source(키보드, 파일...) --> 데이터의 흐름 --> Destination (모니터, 파일...)
  (3) 특징
     <1> FIFO 구조
            --> 흘러가는 데이터의 순서가 바뀔 수 없다.
     <2> 단방향
            --> 흐름의 방향은 일정하다.
     <3> 지연성
            --> 흐름은 지연될 수 있다.
     <4> 유연한 구조
            --> 다른 Stream(FilterStream)으로 연결해서 쓸 수 있다.

                ex) new BufferedReader (new InputStreamReader(System.in));
                     new BufferedReader (new FileReader(""));

  (4) 구분
     <1> by byte
            [1] 1 byte Stream
            [2] 2 byte Stream (문자 스트림) - java언어에만 존재
     <2> by 입출력 - 기준에 따라 달라질 수 있다.
            [1] Input Stream (Reader)
            [2] Output Stream (Writer)

2. NodeStream
  근본 스트림 (ex:수도)
  --> Data Source(원천지) 또는 Data Destination(목적지)와 직접 연결된 Stream
  (1) InputStream (System.in)
       --> read(), read(b), read(b, 0, len)
  (2) OutputStream & PrintStream (System.out)
       --> print(), println(), write()
  (3) FileInputStream
  (4) FileOutputStream
  (5) FileReader (문자스트림 - 2byte)
  (6) FileWriter (문자스트림 - 2byte)

3. FilterStream (내부적으로 buffer를 사용함.)
  응용 스트림 (ex:샤워기)
  --> NodeStream에 연결해서 다양한 기능(메소드)을 쓸 수 있는 Stream
  (1) BufferedInputStream
  (2) BufferedOutputStream //반드시 flush()
  (3) DataInputStream  // 기본형 데이터 & Unicode String을 읽는다.
  (4) DataOutputStream // 기본형 데이터 & Unicode String을 쓴다.
  (5) ObjectInputStream
  (6) ObjectOutputStream
  (7) BufferedReader (문자스트림 - 2byte)
  (8) BufferedWriter (문자스트림 - 2byte) //반드시 flush()
  (9) PrintWriter, PrintStream (문자스트림 - 2byte)
       --> 장점 1.BridgeStream이 필요없다.
                    2.flush() 생략가능 3.메소드다양 
  (10) LineNumberReader
         getLineNumber() 를 이용해서 읽어들인 행의 번호를 알 수 있다.

4. BridgeStream
  다리 스트림
  --> 1byte Stream을 2byte Stream으로 변환해 주는 Stream
  (1) InputStreamReader
  (2) OutputStreamWriter

5. File 클래스
  (1) 설명 : 파일과 디렉토리를 객체로 만들기 위해 설계된 클래스
  (2) 생성자
     <1> File(File parent, String child)
     <2> File(String pathname)
     <3> File(String parent, String child)
     <4> File(URI uri)
   (3) 메소드
     <1> exists()
     <2> getName()
     <3> getPath()
            --> 상대경로를 String으로 리턴
                  getAbsolutePath()
            --> 절대경로를 String으로 린턴
                  getCanconicalPath() throws IOException
            --> 정규화(시스템에서 사용하는 형식)된 절대경로를  String으로 변환
                  ex) 유닉스 --> 심볼릭 링크로 연결된 파일을 실제 경로로 바꾸어준다.
           윈도우 --> 실제 존재하는 파일의 경우 대소문자까지 원래의 경로 및 파일명에 맞추어 준다.    
            참고 ) IOException 은 시스템으로부터 파일시스템 정보를 요청하기 때문에 걸린다.
     <4> getParent()
            --> 전체 경로로 생성해야 결과값이 리턴 됨.
     <5> list()
            --> 파일 객체 하위의 파일과 디렉토리를 String[] 로 리턴
     <6> isDirectory(), isFile(), canRead(), canWrite()
     <7> mkdir()
            --> 부모 디렉토리가 실제 존재해야 자식 디렉토리가 생성
  (4) 필드
     <1> File.separator
            --> OS에 맞는 파일경로 구분자를 리턴해준다.

Posted by 미스터네오
,