1. Iterable이란? Java언어의 Collection framework를 공부하다보면, Collection 인터페이스는 Iterable이라는 상위 인터페이스를 가진것을 확인할 수 있다. Iterate는 "반복한다" 의미를 가지고 있다. 이때, 단순한 반복이 아닌 "어떤 결과를 얻을때까지 반복한다"는 의미를 가지고있다. 그렇다면 Iterable은 무엇을 반복하는것이 가능하도록 한다는 걸까? public interface Iterable { /** * Returns an iterator over elements of type T. * Returns: an Iterator. */ Iterator iterator(); /** * Performs the given action for each element..
1. IP주소와 Port 컴퓨터를 구분하는 주소: IP 컴퓨터 안에 있는 서버들을 구분하는 값: Port 2. 도메인 네임 서버(Domain Name Server: DNS) 도메인 주소를 IP주소로 변환한다. nslookup 도메인 주소 위의 명령으로 도메인에 해당하는 IP주소를 알아낼 수 있다. 3. IP주소 알아내기 InetAddress로 알아낸다. 사용자 컴퓨터의 IP주소 알아내기 InetAddress ia = new InetAdress.getLocalHost(); System.out.prinln(ia.getHostAdress()); google IP주소 알아내기 InetAddress[] iaArr = InetAddress.getAllByName("www.google.com"); for(InetAd..
1. ObjectInputSteam, ObjectOutputStream 직렬화 가능한 대상을 읽고, 쓸 수 있다. 직렬화 가능한 대상은 기본형 타입 또는 java.io.Serializable 인터페이스를 구현하고 있는 객체이다. Serializable - 메소드가 없는 인터페이스로 마크 인터페이스라고 부른다 객체 직렬화란? 데이터 구조를 다른 환경에 전송/저장하기 위하여 바이트(Byte) 포맷으로 변환하는 과정을 말한다. write object -> byte흐름으로 변경되어 전송 -> file, memory에 저장 --역직렬화--> Object(객체) 2. 코드로 작성하기 2-1. Serializable 인터페이스를 구현한 User class 작성 package io; import java.io.Seri..
import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; public class _09_DataIOExam { public static void main(String[] args) throws Exception{ //문제 - 이름, 국어, 영어, 수학, 총점, 평균 점수를 /tmp/score.dat 파일에 입력하시오. String name = "Kim"; int kor = 90; int eng = 85; int math = 95; int total = kor + eng + math; double average = (double)(t..