Created
November 9, 2012 15:32
-
-
Save kazua/4046329 to your computer and use it in GitHub Desktop.
ファイル検索(ファイル名)
This file contains 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
import java.io._ | |
object filesearch { | |
def filesearch(path : String, schwds : String){ | |
try{ | |
new File(path).listFiles.map{ | |
case d if d.isDirectory() => filesearch(d.getPath(), schwds) | |
case f if f.isFile() && f.getName().contains(schwds) => println(f.getPath()) | |
case e => e | |
} | |
}catch{ | |
case ex : java.lang.NullPointerException => println("%s:%s".format(path, "検索不可ディレクトリです")) | |
case ex2 : java.io.IOException => println("%s:%s".format(path, "ファイルにアクセスできません")) | |
} | |
} | |
def main(args: Array[String]) { | |
filesearch(args(0), args(1)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment