목록전체 글 (75)
Super Coding Addict
실제 읽고 쓰는 기능은 없지만, 보조적 기능을 add-on [Decorator] * 보조 스트림 - FilterInputStream과 FilterOutputStream이 최상위 클래스 - 생성자의 매개변수로 또 다른 스트림을 가짐 - 데코레이터 패턴 * 여러가지 보조 스트림 사용하기 - Buffered스트림 : 내부에 8192 바이트 (약 8K) 배열을 가지고 있으며, 읽거나 쓸 때 속도가 빠르다 (8K정도만큼 한꺼번에 읽고 쓰고 하기 때문에) - DataInputStream / DataOutputStream : 데이터의 자료를 그대로 저장하고 읽을 수 있는 스트림 - 예제 # FileCopy 클래스 --> FileInputStream과 FileOutputStream을 이용해 zip파..
* FileReader와 FileWriter - 파일의 문자를 읽고 쓸 때 가장 많이 사용하는 클래스 - 예제 # FileReader 클래스 --> 읽어올 텍스트 파일 --> 이것을 FileInputStream으로 읽게 되면? package Ch14.stream.reader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class FileReaderTest { public static void main(String[] args) throws IOException { FileInputStream fis = new FileInputSt..
* 바이트 단위 스트림 InputStream : 바이트단위 입력스트림 최상위 클래스 (FileInputStream, ByteArrayInputStream, FilterInputStream...) OutputStream : 바이트단위 출력스트림 최상위 클래스 (FileOutputStream, ByteArrayOutputStream, FilterOutputStream...) * FileInputStream과 FileOutputStream 사용하기 - 파일의 한 바이트씩 자료를 읽고 쓰는데 사용 --> 한글과 같은 문자는 X (FileReader, FileWriter를 사용해야함) - 입력 스트림은 파일이 없으면 예외 발생시키는 반면, 출력 스트림은 파일을 생성하여 출력함 -..
* System 클래스의 표준 입출력 멤버 public static System{ public static PrintStream out; //표준 출력 스트림 public static InputStrem in;//표준 입력 스트림 public static PrintStream err;//표준 에러 스트림 } --> static 멤버이기 때문에 new System()하지 않고, System.out 식으로 가져다가 써옴 * System.in 사용하여 입력 받기 - 한 바이트씩 읽어 들인다 - 따라서 한글과 같이 여러 바이트로 된 문자들을 읽기 위해선, InputStreamReader와 같은 보조스트림 + - 예제 # SystemInTest 클래스 package Ch14.stream.inp..
* 입출력 스트림 - 다양한 입출력 장치에 독립적으로 일관성 있는 입출력 방식을 제공한다 - 가상경로를 통해 입력, 출력이 이루어진다고 보면됨 (추상화) - I/O 스트림 사용하여 입출력 구현 * 입출력 스트림 구분 I/O 대상 기준 : 입력 스트림, 출력 스트림 자료의 종류 : 바이트 스트림(1바이트씩 읽어 들이고 1바이트씩 쓰는 스트림으로 동영상이나 음악파일 등), 문자 스트림(문자는 2바이트씩 처리) 스트림의 기능 : 기반 스트림, 보조 스트림(읽거나 쓰는 기능은 없지만 기반 스트림을 서포트해주는 기능을 추가함, 바이트를 읽은 것을 문자로 바꿔준다던가, 버퍼링 기능 제공, 직렬화 등을 함) --> 뒤에 Stream이 붙으면 바이트 단위의 스트림 * 기반 스트림과 보조 스트..
* deadlock - 2개 이상의 Thread가 서로 기다림 * wait()와 notify() 메서드 - wait() : 리소스는 한정적이므로 리소스가 유효하지 않을 때 다시 available할 때까지 thread가 non-runnable상태로 전환되어 대기 --> notify()가 호출될 때까지 기다림 - notify() : wait()하고 있는 하나의 thread를 runnable하게 깨운다 (but the oldest가 아니라, 아무 thread나 깨움!) -. notifyAll() : wait()하고 있는 모든 thread를 깨움 --> notifyAll()이 더 권장됨, 모든 thread를 다 깨워서 서로 CPU 점유 경쟁을 하게한 후, non-runnable한 thread는 다시 잠들게 된다..