Programming/Java2014. 5. 15. 11:06
이해한 개념이 맞으려나
checked exception은 컴파일러나 jvm에 의해 말그대로 '걸러낸/확인된' 
자동화된 예외처리 방법이고 자바에서는 예외처리하도록 강제하기 위해
예외처리하지 않으면 에러라 간주하고 진행되지 않는다

unchecked 는
컴파일러에의해 검사되지않은.
개발자에 의해 예상되는 에러들을 미리 처리하는 개념이다

둘 다 예외처리이지만
개발환경(컴파일러/실행환경) 에 의해 도구적/ 시스템적으로 잡냐
개발자에 의해 수작업으로 잡냐의 차이인듯?



자바에서 exception class 에 있는 예외라도
unchecked exception이 있을수 있다. 아니 의외로 많다?

1) Unchecked Exception
The exceptions that are not checked at compile time are called unchecked exceptions, classes that extends RuntimeException comes under unchecked exceptions. Examples of some unchecked exceptions are listed below.

2) Checked Exceptions
Exceptions that are checked at compile-time are called checked exceptions, in Exception hierarchy all classes that extends Exception class except UncheckedException comes under checked exception category. 

[링크 : http://www.beingjavaguys.com/2013/04/exception-handling-in-java-exception.html] 

 A checked exception is an exception that must be either caught or declared in a method where it can be thrown. For example, the java.io.IOExceptionis a checked exception. To understand what is a checked exception, consider the following code:

[링크 : http://en.wikibooks.org/wiki/Java_Programming/Checked_Exceptions] 
 
 Unchecked, uncaught or runtime exceptions are exceptions that are not required to be caught or declared, even if it is allowed to do so. So a method can throw a runtime exception, even if this method is not supposed to throw exceptions. For example, ConcurrentModificationException is an unchecked exception.

The unchecked exceptions can only be the RuntimeException and its subclasses, and the class Error and its subclasses. All other exception classes must be handled, otherwise the compiler gives an error.

Sometime it is desirable to catch all exception for logging purposes, then throw it back on. For example, in servlet programming when application server calls the server doPost(), we want to monitor that no exception even runtime exception happened during serving the request. The application has its own logging separate from the server logging. The runtime exceptions would just go through without detecting it by the application. The following code would check all exceptions, log them, and throw it back again.

[링크 : http://en.wikibooks.org/wiki/Java_Programming/Unchecked_Exceptions 

'Programming > Java' 카테고리의 다른 글

predefined annotation /java  (0) 2014.06.27
JUnit tutorial  (0) 2014.06.27
Class.forName  (0) 2014.05.09
JDNI - Java Directory & Naming Interface  (0) 2014.05.09
jdk 1.5 - annotation / @  (0) 2014.05.08
Posted by 구차니
프로그램 사용/eclipse2011. 11. 16. 19:46

알고보니 오른쪽 상단에 떡하고 존재 -ㅁ-
이걸 몰랐으니.. 디버그 누르면 왜 창의 모양이 죄다 바껴버리는지 알수가 없었는데
이렇게 황당한 곳에서 버젓이 숨어있었다니.. OTL


'프로그램 사용 > eclipse' 카테고리의 다른 글

eclipse에서 background로 돌려버린 다이얼로그 살려내기  (0) 2012.01.18
eclipse에서 프로젝트 열기  (0) 2011.11.23
eclipse + svn + google code  (0) 2011.11.15
netbeans + eclipse  (0) 2011.10.30
eclipse on ubuntu  (2) 2011.10.24
Posted by 구차니
Programming/Java2011. 11. 15. 22:04
Posted by 구차니
Programming/Java2011. 11. 2. 23:35
public boolean matches(String regex)

matches() 메소드는 정규표현식으로 나타낸 검색어가 String내에 있는지 확인해준다.
정규표현식을 잘 모르지만.. 아무튼 *Manager 로 문자열내에 검색하고 싶으면
matches(".*Manager") 로 하면 된다.

[링크 : http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#matches(java.lang.String)]
[링크 : http://mwultong.blogspot.com/2006/12/java-find-sub-string-in-string.html]
Posted by 구차니
Programming/Java2011. 10. 29. 22:20
File 클래스에서 원하는 경로를 넣고
list() 메소드를 이용하면 그 경로상의 목록을 얻어올수 있다.

만약 원하는 확장자의 파일만을 원한다면
FilenameFilter 클래스를 등록해서 빼내면 되는데 Win32와 차이점은
*.ext 가 아닌 .ext로 해야 한다는 점이다.

import java.io.File;
import java.io.FilenameFilter;
 
    public class FileUtil {
        public void listFiles(String dir) {
            File directory = new File(dir);
            if (!directory.isDirectory()) {
                System.out.println("No directory provided");
                return;
            }
            //create a FilenameFilter and override its accept-method
            FilenameFilter filefilter_java = new FilenameFilter() {
                public boolean accept(File dir, String name) { //if the file extension is .txt return true, else false
                    return name.endsWith(".java");
                }
            };

            String[] filenames = directory.list(filefilter_java);
            for (String name : filenames) {
                System.out.println(name);
            }
        }
    } 

[링크 : http://www.javadb.com/list-files-of-a-certain-type]
[링크 : http://www.roseindia.net/java/java-get-example/get-file-list.shtml]
Posted by 구차니