문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
groovy:file [2013/01/27 14:53] kwon37xi |
groovy:file [2019/03/07 11:15] (현재) kwon37xi |
||
|---|---|---|---|
| 줄 2: | 줄 2: | ||
| * [[http:// | * [[http:// | ||
| * [[http:// | * [[http:// | ||
| + | * [[http:// | ||
| + | |||
| + | ===== 파일 이름 ===== | ||
| + | * [[http:// | ||
| + | file.name.replaceFirst(~/ | ||
| + | </ | ||
| ===== 텍스트 파일 ===== | ===== 텍스트 파일 ===== | ||
| <code groovy> | <code groovy> | ||
| 줄 18: | 줄 24: | ||
| * '' | * '' | ||
| + | ==== 디렉토리의 파일 목록 필터링 ==== | ||
| + | * [[http:// | ||
| + | * 특정 확장자의 파일 목록을 구하는 예<code groovy> | ||
| + | |||
| + | def filesByExt(ext) { | ||
| + | File dir = new File(' | ||
| + | dir.listFiles(new FilenameFilter() { | ||
| + | public boolean accept(File f, String filename) { | ||
| + | return filename.endsWith(' | ||
| + | } | ||
| + | }) | ||
| + | } | ||
| + | |||
| + | List movies = filesbyExt(' | ||
| + | </ | ||
| + | * Groovy 스럽게 바꾸면 [[http:// | ||
| + | def filesByExt(ext) { | ||
| + | new File(' | ||
| + | } | ||
| + | </ | ||
| + | ==== 현재 디렉토리의 동영상 파일을 E?? 에 따라 이름 줄이기 ==== | ||
| + | 현재 디렉토리에 '' | ||
| + | <code groovy> | ||
| + | new File(' | ||
| + | </ | ||
| + | ===== 참조 ===== | ||
| + | * [[https:// | ||