본문 바로가기
728x90
반응형

java26

[Java] 사용 가능한 모든 Locale, Country 조회 java.util.Locale 를 사용합니다. 사용 가능한 모든 Locale 객체 조회 Locale[] availableLocales = Locale.getAvailableLocales(); 모든 Locale 객체의 Country 조회 String[] countries = Locale.getISOCountries(); [Reference] https://docs.oracle.com/javase/7/docs/api/java/util/Locale.html 2022. 6. 3.
[JAVA8] null 대신 Optional 그동안 NullPointerException을 피하기 위해 어떻게 해결해 왔을까?다음은 null 확인 코드를 추가해서 NullPointerException을 줄이려는 코드입니다.// null 안전시도 1: 깊은 의심public String getCarInsuranceName(Person person) { if (person != null) { // null 확인 Car car = person.getCar(); if (car != null) { // null 확인 Insurance insurance = car.getInsurance(); if (insurance != null) { // null 확인 .. 2022. 4. 24.
[APPLE API] App Store Server API 요청을 위한 JWS 토큰 Generating Tokens for API Requests JWT(JSON Web Token)는 정보를 안전하게 전송하는 방법을 정의하는 공개 표준 (RFC 7519) 입니다.App Store Service API는 고객의 인앱  구매에 대한 정보를 요청하고 제공하기 위해 서버에서 호출하는 REST API 인데, API에 대한 각 요청을 승인하기 위해 JWT가 필요합니다.토큰을 생성하고 App Store Connect에서 다운로드한 개인키로 서명합니다. JWS(JSON Web Signature) : JWT header + JWT payload + Sign- 서버에서 인증을 증거로 인증 정보를 서버의 private key로 서명한 것을 Token한 것  JWS 구성JWT HeaderApp Store S.. 2021. 12. 23.
[JAVA] 파일 암호화 (Encrypt file using java) 1. 이미지 파일 암호화/복호화 public class ImgCryptUtils { private int KEY = 123; // key is act as password to Encrypt and Decrypt the Image private String FILE_PATH = "C:\\Users\\moonsiri\\Downloads\\photo.jpg"; public void encrypt() throws IOException { // Selecting a Image for operation FileInputStream fis = new FileInputStream(FILE_PATH); // Converting Image into byte array, create a array of same size .. 2021. 11. 1.
[Java] LocalDateTime format to string, LocalDateTime parse string 1. LocalDateTime format to string String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) 2. LocalDateTime parse string LocalDateTime dateTime = LocalDateTime.parse("2021-06-11 13:37:33", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) 2021. 6. 11.
[Java] POI 라이브러리로 엑셀에 이미지 삽입하기 canvas로 이루어져 있는 차트 이미지를 엑셀 파일에 삽입해보겠습니다.  toDataURL()을 사용하여 원하는 영역을 base64 문자열로 읽어 back단에 데이터를 전달합니다.const imageData = $("#load-graph").find("canvas")[0].toDataURL("image/png", 0.5); 만약 canvas로 그려지지 않은 영역을 이미지로 저장하고 싶다면, html2canvas.js 라이브러리를 사용하여 html 영역을 canvas로 변경하면 됩니다.html2canvas($("#chart")[0]).then(function(canvas) { const imageData = canvas.toDataURL("image/png"); ... 엑셀에 이미지 삽입하는 .. 2021. 5. 7.
[java] Enum Hierarchy(계층 구조) getChildren, getParent 간단한 계층 구조 구현을 위해 Enum을 활용할 수 있습니다. @Getter public enum EnumHierarchy { A("에이", null), AA("에이에이", A), AB("에이비", A), AC("에이씨", A), ACA("에이씨에이", AC), ACB("에이씨비", AC), AD("에이디", A), B("비", null), C("씨", null), D("디", null), DA("디에이", D), ; private String name; private EnumHierarchy parent; private List children = new ArrayList(); EnumHierarchy(String name, EnumHierarchy parent) { this.name = name; t.. 2021. 2. 2.
[java] 쿠키 생성, 삭제와 browser's cookie max size JAVA 쿠키 생성, 삭제 방법을 알아보기 전에 브라우저의 쿠키 사이즈 제한을 확인해봅시다. cookies are usually limited to 4096 bytes and you can't store more than 20 cookies per site. By using a single cookie with subkeys, you use fewer of those 20 cookies that your site is allotted. In addition, a single cookie takes up about 50 characters for overhead (expiration information, and so on), plus the length of the value that you store .. 2021. 1. 8.
[Java8] 중복 데이터 제거를 위한 Stream distinct 중복 데이터를 제거하기 위해 Stream distinct를 사용합니다. 동일한 객체의 판단하는 기준은 Object.equals(Object)의 결과 값이다. String 객체의 경우 equals()가 이미 구현되어 있습니다. ​ - Stream.distinct() : Returns a stream consisting of the distinct elements (according to Object.equals(Object)) of this stream. List strings = Arrays.asList("hello", "world", "hello", "java", "hello"); strings.stream().distinct().forEach(System.out::println); // "hello".. 2020. 10. 31.
[java] StringBuffer getChars (Chars to String) https://www.tutorialspoint.com/java/lang/stringbuffer_getchars.htm Java.lang.StringBuffer.getChars() Method - Tutorialspoint Java.lang.StringBuffer.getChars() Method Description The java.lang.StringBuffer.getChars() method copy the characters from this sequence into the destination character array dst. The first character to be copied is at index srcBegin. The last character to www.tutorialspoin.. 2020. 10. 31.
728x90
반응형