Java(156)
-
숫자 6자리 임시 비밀번호 만들기
import java.security.SecureRandom;public class TemporaryPasswordGenerator { public static String generateTempPassword() { SecureRandom secureRandom = new SecureRandom(); // Generate a random number between 100000 and 999999 int tempPassword = 100000 + secureRandom.nextInt(900000); return String.valueOf(tempPassword); } public static void main(String[] args) {..
2024.11.19 -
깨진 Hex Code decode 하기
깨진 문구Test \\xED\\x99\\x94\\xEB\\xA9\\xB4 \\xED\\x99\\x94\\xEB\\xA9\\xB4 !!decodeString input = "Test \\xED\\x99\\x94\\xEB\\xA9\\xB4 \\xED\\x99\\x94\\xEB\\xA9\\xB4 !!";// Sanitize the input to keep only valid hexadecimal charactersString decoded = decodeHex2String(input);System.out.println("Decoded String: " + decoded);public static String decodeHex2String(String input) { // A list to collect ..
2024.11.17 -
Spring boot에서 java 변수값을 템플릿에 출력하기
javaimport org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.GetMapping;@Controllerpublic class MyController { @GetMapping("/show-variable") public String showVariable(Model model) { String message = "Hello, Spring Boot!"; model.addAttribute("myVariable", message); // Add the variable to the model ..
2024.11.17 -
List<Map<String, Object>>에 item 추가하기
new를 사용import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;public class Main { public static void main(String[] args) { // Initialize the list List> list = new ArrayList(); // Create a new map Map item = new HashMap(); item.put("key1", "value1"); item.put("key2", 123); // You can add any type of object here ..
2024.11.12 -
hostname 정보 가져오기
InetAddress.getLocalHost();
2024.11.12 -
mybatis를 이용해서 BLOB 저장
이미지를 byte[]로 변환import java.io.File;import java.io.FileInputStream;import java.io.IOException;public byte[] readImage(String filePath) throws IOException { File file = new File(filePath); FileInputStream fis = new FileInputStream(file); byte[] imageBytes = new byte[(int) file.length()]; fis.read(imageBytes); fis.close(); return imageBytes;}mybatis 사용하지 않고, BLOB 저장import java.sql..
2024.11.07