전체 글
-
[Java] 날짜,시간과 관련된 LocalDateTime의 역사Java 2022. 8. 27. 00:01
Java 1.0 Date 클래스 자바 1.0부터 java.util.Date 클래스 하나로 날짜와 시간관련 기능을 제공했습니다. Date라는 클래스의 이름과 달리 특정 시점을 날짜가 아닌 밀리초 단위로 표현합니다. 또한 1900년을 기준으로 시작하는 오프셋, 0에서 시작하는 달 인덱스 등 모호한 설계로 유용성이 떨어집니다. 2017년 9월 21일 가리키는 Date 인스턴스를 만드는 코드 Date date = new Date(117,8,21); //출력 //Thu Sep 21 00:00:00 KST 2017 Java 1.1 Calendar 클래스 자바 1.1에서는 Date클래스의 여러 메서드를 deprecate시키고 Calendar 클래스를 대안으로 제공합니다. 1900년을 기준으로 시작하는 오프셋은 없앴지..
-
가상메모리CS/운영체제 2022. 8. 26. 00:01
메모리란? 메모리란 프로그램과 프로그램 수행에 필요한 데이터 및 코드를 저장하는 장치입니다. 가상 메모리의 등장 배경 만약 컴퓨터에서 가지고 있는 RAM의 용량보다 애플리케이션이 실행되는데 필요한 RAM의 용량이 더 크면 어떻게 될까요? 프로그램을 절대 실행할 수 없게 됩니다. 따라서 가상 메모리 기법은 애플리케이션의 일부분만 메모리에 올려 실행하도록 합니다. 실제로 프로세스 전체가 물리적 메모리에 있는 것처럼 수행되지만 사실은 일부만 메모리에 존재하고 나머지는 디스크에 있습니다. 즉, 가상 메모리는 물리적 메모리 크기의 한계를 극복하기 나온 기술입니다. Page Fault(페이지 부재) 만약 CPU에서 접근하려는 페이지가 메모리에 없는 경우입니다. 페이지 테이블의 valid bit가 0이라면 CPU에 ..
-
[백준] 10814번 : 나이순 정렬알고리즘/백준 2022. 8. 25. 00:01
https://www.acmicpc.net/problem/10814 10814번: 나이순 정렬 온라인 저지에 가입한 사람들의 나이와 이름이 가입한 순서대로 주어진다. 이때, 회원들을 나이가 증가하는 순으로, 나이가 같으면 먼저 가입한 사람이 앞에 오는 순서로 정렬하는 프로그램을 www.acmicpc.net 문제 해석 정렬을 잘할 수 있는지 묻는 문제입니다. 나이순으로 그리고 나이가 같다면 가입한 순으로 정렬합니다. 문제 풀이 전 설계 람다와 스트림을 통해 해결해보려고 합니다. Member 클래스를 두고 나이, 가입한 순으로 Comparator를 구현합니다. 출력은 stream의 forEach로 값을 쌓아두고 출력합니다. 코드 import java.io.BufferedReader; import java.i..
-
MultipartFile 컨트롤러 단위 테스트(MockMvc)프로젝트/미디어 스트리밍 서버 프로젝트 2022. 8. 24. 01:03
컨트롤러 메서드 @PostMapping(consumes = [MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE]) fun fileUpload( @RequestPart request: UploadRequest, @RequestPart file: MultipartFile ): ResponseEntity { // todo : videoService 에서 upload 이후 반환되는 아이디 및 등록 과정 필요 metadataService.registerMetadata(file) val uploadResponse = videoService.upload(request, file) return ResponseEntity( BasicRespons..
-
[백준] 2164번 : 카드2 - 자바(JAVA)알고리즘/백준 2022. 8. 24. 00:01
https://www.acmicpc.net/problem/2164 2164번: 카드2 N장의 카드가 있다. 각각의 카드는 차례로 1부터 N까지의 번호가 붙어 있으며, 1번 카드가 제일 위에, N번 카드가 제일 아래인 상태로 순서대로 카드가 놓여 있다. 이제 다음과 같은 동작을 카드가 www.acmicpc.net 문제 해석 Stream을 통해서 N까지 번호를 생성하고 LinkedList를 통해 removeFirst, removeLast 등의 연산을 통해 효율적으로 카드 제거 및 옮기기를 수행합니다. 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Link..
-
Kotest와 MockK를 활용하여 컨트롤러 단위테스트하기프로젝트/미디어 스트리밍 서버 프로젝트 2022. 8. 23. 18:55
개요 JUnit5와 @WebMvcTest를 이용한 컨트롤러 단위 테스트는 익숙하지만 Kotest와 MockK를 활용한 @WevMvcTest를 수행하고자 합니다. 일단 아주 간단한 테스트 컨트롤러를 하나 만들고 단위테스트를 진행해보겠습니다. TestController @RestController class TestController { private val test = "test" @GetMapping fun test(): String { return test } } Controller 단위 테스트 @WebMvcTest(TestController::class) class MyTest3 constructor(@Autowired val mockMvc: MockMvc) : BehaviorSpec({ given(..
-
스트림으로 데이터 수집Java/모던자바인액션요약 2022. 8. 23. 00:01
개요 만약 통화별로 트랜잭션을 그룹화하기 위해서 코드를 작성하려면 어떻게 해야 할까요? Map transactionByCurrencies = new HashMap(); //트렌젝션 리스트에서 하나씩 꺼내옴 for(Transaction transaction : transactions){ Currency currency = transaction.getCurretncy(); List transactionForCurrency = transactionByCurrencies.get(currency); if(transactionForCurrency == null){ transactionForCurrency = new ArrayList(); transactionByCurrencies.put(currency, trans..
-
ffmpeg install (Mac OS, Amazon Linux)프로젝트/미디어 스트리밍 서버 프로젝트 2022. 8. 22. 13:12
Homebrew로 FFmpeg 설치하기 다음 명령어를 실행하면 바로 FFmpeg이 설치됩니다. 의존 패키지가 많아서 시간이 좀 걸립니다. $ brew install ffmpeg ... ==> Installing ffmpeg ==> Pouring ffmpeg--5.0.arm64_big_sur.bottle.1.tar.gz 🍺 /opt/homebrew/Cellar/ffmpeg/5.0: 272 files, 48.8MB ... FFmpeg을 설치하고 ffmpeg을 인자 없이 실행하면 버전, 빌드 옵션, 기본적인 사용 방법이 출력됩니다. $ ffmpeg ffmpeg version 5.0 Copyright (c) 2000-2022 the FFmpeg developers built with Apple clang ver..