사용자 도구

사이트 도구


groovy:file

문서의 이전 판입니다!


Groovy File

파일 이름

  • 파일 이름에서 확장자 빼고 이름만
    file.name.replaceFirst(~/\.[^\.]+$/, '')

텍스트 파일

def file = new File('filename.txt')
 
def text = file.text // 전체 텍스트
 
// 각 줄을 읽어서 처리
file.eachLine { line ->
  println "# ${line}"
}

디렉토리

  • new File('.').directorySize() : 디렉토리 크기 구하기. Groovy 2.1

디렉토리의 파일 목록 필터링

groovy/file.1368769610.txt.gz · 마지막으로 수정됨: 2013/05/17 14:46 저자 kwon37xi