Language/Java

import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; public class FileZipCreate { //zip파일 생성 메서드 public static void zipDirectory(String dir, String zipfile) throws IOException, IllegalArgumentException { //디렉토리 존재 유무 체크 및 해당 파일 리스트를 가져오기 위하여 객체 생성 File d = new File(di..
import java.text.DecimalFormat; public class Price1000Comma { public static void main(String[] args) { DecimalFormat df = new DecimalFormat("#,###.######"); double amtDouble = 1234567890.123456; String amtString = df.format(amtDouble); System.out.println(amtString); } }
기능 1. 대용량 데이터를 엑셀로 내려 받음. 2. 셀 머지 기능 3. 시트별로 데이터를 출력 ※ xml를 사용한 방법 ※ xml를 사용하지 않고 RowHandler만 사용한 방법 ( 이경우는 데이터가 많은경우 Out Of Memory가 발생 하였음) 첨부파일에 컨트롤러 파일을 참고 설명 일반적으로 엑셀로 대용량 데이터를 내려 받을경우 Out Of Memory 가 발생하게 된다. 그래서 Heap Size를 늘려주기도 하고 데이터를 나눠서 엑셀로 내려받는 등 여러가지 방법으로 구현하기도 한다. 이러한 문제점들을 해결할수 있게 XML 형식으로 대용량 처리하여 엑셀로 내려 받을수 있게 되는데 스프링, iBatis(myBatis), poi등을 이용하여 구현하게 된다. 일반적으로 엑셀 내려받기 위하여 10만건을 ..
import java.text.DecimalFormat; public class ByteCal { public String byteCalculation(String bytes) { String retFormat = "0"; Double size = Double.parseDouble(bytes); String[] s = { "bytes", "KB", "MB", "GB", "TB", "PB" }; if (bytes != "0") { int idx = (int) Math.floor(Math.log(size) / Math.log(1024)); DecimalFormat df = new DecimalFormat("#,###.##"); double ret = ((size / Math.pow(1024, Math.flo..
방법1 public class NumberCheck { public static void main(String[] args) { System.out.println("## 숫자 체크 정수, 실수 : " + isStringDouble("1500")); System.out.println("## 숫자 체크 정수, 실수 : " + isStringDouble("1500.123")); System.out.println("## 숫자 체크 정수, 실수 : " + isStringDouble("1500T")); } public static boolean isStringDouble(String s) { try { Double.parseDouble(s); return true; } catch (NumberFormatExcept..
import java.security.SecureRandom; public class RandomTest { public static void main(String[] args) { /* * Math.random()은 취약하다는 보안검사를 통해서 이야기를 들은적이 있다. * 따라서 new SecureRandom()를 쓰기를 권장한다. */ System.out.println("Math.random() : "+Math.random()); System.out.println("SecureRandom() : "+new SecureRandom().nextDouble()); } }
public class CipherTest { public static void main(String[] args) throws Exception { //String encryptKey = "암호화키"; //22db8b13823131fa58928507ad7add61 : 암호화키 //String iv = "IV키"; //02130995e8a1bfbffd39df4e3bd5b344 : IV키 String txt = "여기에 암호화할 문자를 입력해주세요."; String enc = new String(CipherUtil.AES_Encode(txt , "22db8b13823131fa58928507ad7add61", "02130995e8a1bfbffd39df4e3bd5b344")); String str = new ..
728x90
반응형
공손(gongson)
'Language/Java' 카테고리의 글 목록