인강 보습 (인프런,유데미,패스트캠퍼스) (50) 썸네일형 리스트형 입출력과 파일 (2) 파일 다루기 import java.io.File; import java.io.IOException; public class _03_File { public static void main(String[] args) { // 파일 생성 + 정보 얻어오기 String fileName = "test.txt"; File file = new File(fileName); try { file.createNewFile(); // 파일 생성 if (file.exists()) { System.out.println("파일 이름 : " + file.getName()); System.out.println("파일 절대 경로 : " + file.getAbsolutePath()); System.out.println("파일 크기 (By.. 입출력과 파일 (1) 입력 import java.util.Scanner; public class _01_Input { public static void main(String[] args) { // 사용자 입력 Scanner sc = new Scanner(System.in); // System.out.println("이름을 입력하세요"); // String name = sc.next(); // System.out.println("혈액형을 입력하세요"); // String bloodType = sc.next(); // System.out.println("키를 입력하세요"); // // int height = Integer.parseInt(sc.next()); // int height = sc.nextInt(); // System.. 쓰레드 (2) - 다중쓰레드, 동기화 멀티쓰레드 public class _04_MultiThread { public static void main(String[] args) { Runnable cleaner1 = new Runnable() { @Override public void run() { System.out.println("-- 직원1 청소 시작 --"); for (int i = 1; i { System.out.println("-- 직원2 청소 시작 --"); for (int i = 2; i 쓰레드 - (1) Thread, Runnable, Join Thread _01_Thread public class _01_Thread { public static void main(String[] args) { // 하나의 프로세스 (Process) // 쓰레드 (Thread) // 1 3 5 7 9 // 2 4 6 8 10 // cleanBySelf(); CleanThread cleanThread = new CleanThread(); // cleanThread.run(); // 직원 청소 cleanThread.start(); cleanByBoss(); // 사장 청소 } public static void cleanBySelf() { System.out.println("-- 혼자 청소 시작 --"); for (int i = 1; i 예외처리 (2) - Finally, Try with Resources, 사용자 정의 예외, 예외처리미루기 Finally 구문 package chap_11; public class _04_Finally { public static void main(String[] args) { try { System.out.println("택시의 문을 연다."); throw new Exception("휴무 택시"); // System.out.println("택시에 탑승한다."); } catch (Exception e) { System.out.println("!! 문제 발생 : " + e.getMessage()); } finally { System.out.println("택시의 문을 닫는다."); } // try + catch(s) // try + catch(s) + finally // try + finally System.o.. 예외처리 - (1) Try Catch , Catch구문, Throw, 예외처리 (Try Catch) package chap_11; public class _01_TryCatch { public static void main(String[] args) { // 예외 처리 // 오류 : 컴파일 오류, 런타임 오류 (에러 error, 예외 exception) try { // System.out.println(3 / 0); // int[] arr = new int[3]; // arr[5] = 100; Object obj = "test"; System.out.println((int) obj); } catch (Exception e) { System.out.println("이런 문제가 발생했어요 => " + e.getMessage()); e.printStackTrace(); } Sy.. 익명 클래스, 람다와 스트림 - (2) 함수형 인터페이스, 스트림 함수형 인터페이스 (전반전) _04_FunctionalInterface public class _04_FunctionalInterface { public static void main(String[] args) { KRWConverter converter = new KRWConverter(); // converter.convert(2); // convertUSD((USD) -> System.out.println(USD + " 달러 = " + (USD * 1400) + " 원"), 1); Convertible convertible = (USD) -> System.out.println(USD + " 달러 = " + (USD * 1400) + " 원"); convertUSD(convertible, 2); Co.. 익명 클래스, 람다와 스트림 - (1) 익명클래스, 람다 익명 클래스 public class _01_AnonymousClass1 { public static void main(String[] args) { class Coffee { public void order(String coffee) { System.out.println("주문하신 " + coffee + " 나왔습니다."); } Coffee c1 = new Coffee(); c1.order("아메리카노"); System.out.println("----------------"); Coffee c2 = new Coffee(); c2.order("라떼"); System.out.println("----------------"); // 굉장히 친한 친구 방문 Coffee specialCoffee = new Cof.. 이전 1 2 3 4 5 6 7 다음