JAVA 파일 검색 코드

Programming/JAVA,JSP 2013. 12. 28. 17:03 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

import java.io.File;

import java.io.IOException;

 

public class FileTest {

           public static void main(String[] args) throws IOException {

                     String name = "c:/";                 

                     searchDirectory(name);

                    

 

           }

 

           static void searchDirectory(String name) {

                     File dir = new File(name);

                     String[] fileNames = dir.list();

                     for (String s : fileNames) {

                               

                                File f = new File(name + "/" + s); // 절대 경로로 이름을 주어야 함

                                if( f.isHidden())

                                {

                                          continue;

                                }

                                System.out.println("===============================");

                                System.out.println("이름: " + f.getName());

                                if( f.getName().equals("c01.bmp"))

                                          //

                                          if(f.getName().contains("c01"))

                                {

                                          System.err.println("Find Out!!!!");

                                          System.exit(0);

                                }

                                System.out.println("경로: " + f.getPath());

                                if( f.isDirectory() )

                                {

                                          searchDirectory(name + "/" + s);

                                }

                                System.out.println("===============================");

                     }

           }

}

 

'Programming > JAVA,JSP' 카테고리의 다른 글

JAVA Calendar #2  (0) 2013.12.31
Calendar #1  (0) 2013.12.31
JAVA GUI 계산기 소스코드  (0) 2013.12.22
JAVA 소수를 구하는 프로그램 GUI #2  (0) 2013.12.21
JAVA 소수를 판단하는 GUI 프로그램  (0) 2013.12.21