Java(140)
-
예외가 발생해도 계속 진행하고, 마지막에 예외 발생하기
public class FileUtils { public static List getFiles(String directory) { try(Stream filePaths = Files.walk(Paths.get(directory))) { return filePaths .filter(Files::isRegularFile) .collect(Collectors.toList()); } catch(IOException e) { e.printStackTrace(); return List.of(); } }}public class Main { public static void main(String[] args) { List files = FileUtils.getFiles(..
2024.11.06 -
Recursive 파일 정보 가져오기
public class FileUtils { public static List getFiles(String directory) { try(Stream filePaths = Files.walk(Paths.get(directory))) { return filePaths .filter(Files::isRegularFile) .collect(Collectors.toList()); } catch(IOException e) { e.printStackTrace(); return List.of(); } }}
2024.11.06 -
String "2024-11-06 11:24:01 +0900"을 Date로 변환
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class DateExample { public static void main(String[] args) { String dateString = "2024-11-06 11:24:01 +0900"; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); try { Date date = formatter.parse(date..
2024.11.06 -
FastAPI에서 이미지 가져오기
Binary를 직접 가져오기pom.xml org.apache.httpcomponents.client5 httpclient5 5.1Spring Boot Codeimport org.springframework.core.io.InputStreamResource;import org.springframework.http.HttpHeaders;import org.springframework.http.MediaType;import org.springframework.http.ResponseEntity;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RequestParam;impo..
2024.10.19 -
Http 통신하기 Apache HttpClient 사용
pom.xml org.apache.httpcomponents.client5 httpclient5 5.1GET 방식import org.apache.hc.client5.http.classic.methods.HttpGet;import org.apache.hc.client5.http.classic.methods.CloseableHttpResponse;import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;import org.apache.hc.client5.http.impl.classic.HttpClients;import org.apache.hc.core5.http.io.entity.EntityUtils;public class HttpClientEx..
2024.10.19 -
Spring boot mapping 설정
Class 차원에서 mapping 설정@RestController@RequestMapping("/image")public class ImageController extends HttpServlet {Method 차원에서 mapping 설정@RequestMapping("/one")public Member getOne(String test) {// GET 방식@GetMapping("/one")public void getOne(String test) {// POST 방식@PostMapping("/one")public void getOne(String test) {
2024.10.01