Created
September 11, 2010 08:06
-
-
Save osima/574976 to your computer and use it in GitHub Desktop.
htm,html の拡張子をもったファイル全部列挙
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// htm,html の拡張子をもったファイル全部列挙. | |
// さらに title 要素を調べる. | |
// | |
import java.util.regex.* | |
class Util { | |
def fff = { it.isFile() && (it.name.endsWith('.htm') || it.name.endsWith('.html') ) } as FileFilter | |
def ffd = { it.isDirectory() } as FileFilter | |
def recur = { dir-> | |
dir.listFiles(fff).each{ htmllist.add(it) } | |
dir.listFiles(ffd).each{ | |
recur( it ) | |
} | |
} | |
def htmllist | |
def proc(){ | |
this.htmllist = [] | |
recur( new File('.') ) | |
this.htmllist | |
} | |
} | |
new Util().proc().each{ file-> | |
def enc = 'UTF-8' | |
def rlist=[] | |
file.newReader(enc).each{ | |
def r = '<title>(.*)</title>' | |
def p = Pattern.compile(r) | |
def m = p.matcher(it) | |
if( m.find() ){ | |
def t = m.group(1) | |
println t | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// htm,html の拡張子をもったファイル全部列挙. | |
// | |
class Util { | |
def fff = { it.isFile() && (it.name.endsWith('.htm') || it.name.endsWith('.html') ) } as FileFilter | |
def ffd = { it.isDirectory() } as FileFilter | |
def recur = { dir-> | |
dir.listFiles(fff).each{ println it } | |
dir.listFiles(ffd).each{ | |
recur( it ) | |
} | |
} | |
def proc(){ | |
recur( new File('.') ) | |
} | |
} | |
new Util().proc() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment