kr.co.hit.live.util
Class FileUtil

java.lang.Object
  extended by kr.co.hit.live.util.FileUtil

public class FileUtil
extends Object

파일 탐색 기능을 제공하는 클래스이다.

Since:
3.0
Author:
김형도

Constructor Summary
FileUtil()
           
 
Method Summary
static boolean deleteDirectory(File dir, boolean include)
          주어진 dir 하위의 내용을 모두 삭제한다.
static Set<File> getAllFilesUnder(File rootDir, FilenameFilter filter)
           지정한 디렉토리와 그 하위 디렉토리 내에 있는 파일들의 목록을 가져온다.
static Set<File> getAllFilesUnder(File rootDir, FilenameFilter filter, boolean subDir)
           지정한 디렉토리와 그 하위 디렉토리 내에 있는 파일들의 목록을 가져온다.
static String[] getClassnamesUnder(String rootDir, String pkgPrefix, boolean excludingRoot)
           지정한 디렉토리와 그 하위 디렉토리 내에 있는 클래스 파일들을 찾아서 그 클래스명을 가져온다.
static String[] getFilenamesUnder(String rootDir, String[] ext, boolean excludingRoot)
           지정한 디렉토리와 그 하위 디렉토리 내에 있는 파일들의 목록을 이름으로 가져온다.
static Set<File> getFilesOfPattern(File[] rootDir, String[] pattern, boolean subDir)
          지정한 디렉토리들에 대하여 각 디렉토리와 그 하위 디렉토리 내에 있는 파일들중에서 주어진 패턴들에 매치되는 파일들의 목록을 가져온다.
static Set<File> getFilesOfPattern(File rootDir, String[] pattern, boolean subDir)
           지정한 디렉토리와 그 하위 디렉토리 내에 있는 파일들중에서 주어진 패턴들에 매치되는 파일들의 목록을 가져온다.
static List<File> getFilesOfPatternAsPatternOrder(File[] rootDir, String[] pattern, boolean subDir)
          지정한 디렉토리들에 대하여 각 디렉토리와 그 하위 디렉토리 내에 있는 파일들 중에서 주어진 패턴들에 매치되는 파일들의 목록을 가져온다.
static Set<File> getFilesWithExtension(File[] rootDir, String[] ext, boolean subDir)
          지정한 디렉토리들에 대하여 각 디렉토리와 그 하위 디렉토리 내에 있는 파일들중에서 주어진 확장자를 가진 파일들의 목록을 가져온다.
static Set<File> getFilesWithExtension(File rootDir, String[] ext, boolean subDir)
           지정한 디렉토리와 그 하위 디렉토리 내에 있는 파일들중에서 주어진 확장자를 가진 파일들의 목록을 가져온다.
static void mergeFile(String targetName, String[] sourceNames, boolean deleteSource)
          여러 개의 파일을 하나의 파일로 합치는 기능을 제공한다.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtil

public FileUtil()
Method Detail

mergeFile

public static void mergeFile(String targetName,
                             String[] sourceNames,
                             boolean deleteSource)
                      throws IOException
여러 개의 파일을 하나의 파일로 합치는 기능을 제공한다.

Parameters:
targetName -
sourceNames -
파일 - 합친 후 소스 파일 삭제 여부
Throws:
IOException

deleteDirectory

public static boolean deleteDirectory(File dir,
                                      boolean include)
주어진 dir 하위의 내용을 모두 삭제한다.

Parameters:
dir - 삭제할 디렉토리
include - dir도 삭제할지 여부
Returns:

getFilenamesUnder

public static String[] getFilenamesUnder(String rootDir,
                                         String[] ext,
                                         boolean excludingRoot)

지정한 디렉토리와 그 하위 디렉토리 내에 있는 파일들의 목록을 이름으로 가져온다.

Parameters:
rootDir - 시작 디렉토리 path 문자열
ext - 가져올 파일들의 확장자 목록을 지정한 String 배열
excludingRoot - true이면 파일이름의 Path명에서 rootFile의 Path명을 제외한다.
Returns:
파일들의 이름 리스트

getClassnamesUnder

public static String[] getClassnamesUnder(String rootDir,
                                          String pkgPrefix,
                                          boolean excludingRoot)

지정한 디렉토리와 그 하위 디렉토리 내에 있는 클래스 파일들을 찾아서 그 클래스명을 가져온다. pkgPrefix를 지정하면 클래스명의 패키지 구조 앞에 pkgPrefix가 붙어서 클래스명이 생성된다.

Parameters:
rootDir - 시작 디렉토리 path 문자열
pkgPrefix - 공통 패키지 명
excludingRoot - true이면 클래스의 패키지명 시작을 rootDir의 위치를 기준으로 생성한다.
Returns:
검색된 클래스 명 리스트

getFilesWithExtension

public static Set<File> getFilesWithExtension(File[] rootDir,
                                              String[] ext,
                                              boolean subDir)
지정한 디렉토리들에 대하여 각 디렉토리와 그 하위 디렉토리 내에 있는 파일들중에서 주어진 확장자를 가진 파일들의 목록을 가져온다.

Parameters:
rootDir - 시작 디렉토리 path 들
pattern - 가져올 파일들의 파일명 패턴 목록(regexp)
subDir - 하위 디렉토리 탐색 여부
Returns:
파일 목록을 담은 Set 객체, 디렉토리가 존재하지 않으면 null

getFilesWithExtension

public static Set<File> getFilesWithExtension(File rootDir,
                                              String[] ext,
                                              boolean subDir)

지정한 디렉토리와 그 하위 디렉토리 내에 있는 파일들중에서 주어진 확장자를 가진 파일들의 목록을 가져온다.

Parameters:
rootDir - 시작 디렉토리 path
pattern - 가져올 파일들의 파일명 패턴 목록(regexp)
subDir - 하위 디렉토리 탐색 여부
Returns:
파일 목록을 담은 Set 객체, 디렉토리가 존재하지 않으면 null

getFilesOfPattern

public static Set<File> getFilesOfPattern(File[] rootDir,
                                          String[] pattern,
                                          boolean subDir)
지정한 디렉토리들에 대하여 각 디렉토리와 그 하위 디렉토리 내에 있는 파일들중에서 주어진 패턴들에 매치되는 파일들의 목록을 가져온다.

Parameters:
rootDir - 시작 디렉토리 path 들
pattern - 가져올 파일들의 파일명 패턴 목록(regexp)
subDir - 하위 디렉토리 탐색 여부
Returns:
파일 목록을 담은 Set 객체, 디렉토리가 존재하지 않으면 empty

getFilesOfPatternAsPatternOrder

public static List<File> getFilesOfPatternAsPatternOrder(File[] rootDir,
                                                         String[] pattern,
                                                         boolean subDir)
지정한 디렉토리들에 대하여 각 디렉토리와 그 하위 디렉토리 내에 있는 파일들 중에서 주어진 패턴들에 매치되는 파일들의 목록을 가져온다. 파일들을 가져오는 순서는 pattern 순서대로 가져오도록 보장한다.

Parameters:
rootDir - 시작 디렉토리 path 들
pattern - 가져올 파일들의 파일명 패턴 목록(regexp)
subDir - 하위 디렉토리 탐색 여부
Returns:
파일 목록을 담은 List 객체, 디렉토리가 존재하지 않으면 empty

getFilesOfPattern

public static Set<File> getFilesOfPattern(File rootDir,
                                          String[] pattern,
                                          boolean subDir)

지정한 디렉토리와 그 하위 디렉토리 내에 있는 파일들중에서 주어진 패턴들에 매치되는 파일들의 목록을 가져온다.

Parameters:
rootDir - 시작 디렉토리 path
pattern - 가져올 파일들의 파일명 패턴 목록(regexp)
subDir - 하위 디렉토리 탐색 여부
Returns:
파일 목록을 담은 Set 객체, 디렉토리가 존재하지 않으면 null

getAllFilesUnder

public static Set<File> getAllFilesUnder(File rootDir,
                                         FilenameFilter filter)

지정한 디렉토리와 그 하위 디렉토리 내에 있는 파일들의 목록을 가져온다.

Parameters:
rootDir - 시작 디렉토리 path
filter - 가져올 파일들의 확장자 목록을 지정한 필터 객체
Returns:
파일 목록을 담은 Set 객체, 디렉토리가 존재하지 않으면 null

getAllFilesUnder

public static Set<File> getAllFilesUnder(File rootDir,
                                         FilenameFilter filter,
                                         boolean subDir)

지정한 디렉토리와 그 하위 디렉토리 내에 있는 파일들의 목록을 가져온다.

Parameters:
rootDir - 시작 디렉토리 path
filter - 가져올 파일들의 확장자 목록을 지정한 필터 객체
subDir - 하위 디렉토리 탐색 여부
Returns:
파일 목록을 담은 Set 객체, 디렉토리가 존재하지 않으면 null


Copyright © 2014. All Rights Reserved.