본문 바로가기

반응형

java

(31)
SqlDaoConverter package my.util; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; /** * * * origin.sql File을 읽어서 DAO에서 사용할 SQL로 바꾸는 Util * 마음대로 배포 및 수정 하셔도 됩니다. * author 만 남겨주세요. * * @author Jeong-Hoon, Kim * * @since Jdk 1.6.0_02 * 2008. 02. 20 */ public class SqlDaoConverter { private String resultSql; /** * 생성자 * @throws IOException */ public SqlDaoConverter() throws IOEx..
System의 Properties static final String NEWLINE = System.getProperty("line.separator"); 위와 같이 선언하면 System의 Property 중 개행 문자를 가져오게 됩니다. Java API에 보면 이와 관련된 목록이 있습니다. Key Description of Associated Value java.version Java Runtime Environment version java.vendor Java Runtime Environment vendor java.vendor.url Java vendor URL java.home Java installation directory java.vm.specification.version Java Virtual Machine specif..
For Each Java 1.4버전이나 그 이전 version에 익숙하신 분들은 보통 for Loop를 구현 할 때 다음과 같이 구현 합니다. method(Collection c){ for(Iterator i = c.iterator();i.hasNext();){ i.next().cancel(); } } 하지만 이러한 구조는 for문의 구조가 복잡해 지면 헷갈리게 될 가능성이 많습니다. 또한 Generic을 사용하지 않음으로서 Collection에 뭐가 들어 있는지도 모릅니다. 그러나 아래와 같이 for each를 사용하면 Collection이나 배열의 요소만큼만 Loop를 자동으로 돌리므로 알기쉽게 Code를 작성할 수 있습니다. method(Collection c){ for(TimerTask t : c){ t.canc..
GregorianCalendar 사용시 주의 사항 Gregorian Calendar 에서 1월을 넣어 주고 싶다면 아래와 같이 하세요. package com.test; import java.util.Calendar; import java.util.GregorianCalendar; public class GregorianCalendarTest { /** * @param agrs * 2008. 01. 18 */ public static void main(String[] agrs){ GregorianCalendar calendar = new GregorianCalendar(); calendar.clear(); calendar.set(Calendar.YEAR, 2008); calendar.set(Calendar.MONTH, 1-1); calendar.set(C..
Package 선언시 주의사항 만일 Package 선언시 java.~~~ 로 시작되는 package를 선언한다면 main Mathod 실행시 Exception 을 뱉어 낸다. java.lang.SecurityException: Prohibited package name: java.sql at java.lang.ClassLoader.preDefineClass(ClassLoader.java:479) at java.lang.ClassLoader.defineClass(ClassLoader.java:614) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java..
for문의 사용 방법 과거에 나는 항상 아래와 같이 for 문을 사용하였다. for(int i=0 ;i
ArrayList에서 add Method 분석 add(Object o) Appends the specified element to the end of this list Throws: IndexOutOfBoundsException - if index is out of range (index size()). add(Object o) Appends the specified element to the end of this list. 먼저 영문을 볼때 해석에 주의 해야겠다. 위의 add Method는 class java.util.ArrayList의 Method이다. 위의 두 Method의 차이점에 대해서 생각해 보자. 같은 Method이지만 arguments에 따라서 Overloading 된다. 중요한 점은 add(int index..

반응형