/**
* @author ezzze
* @version 0.009 2009-7-16
*/
public class FileTest{
def isAuthLine(String str){
return (!str.isEmpty()&&
!str.startsWith('private')&&
!str.startsWith('import')&&
!str.startsWith('package')&&
!str.startsWith('/*')&&
!str.startsWith('*') &&
!str.startsWith('this')
)
}
def cleanThem = {
fileName->
new File('src/').eachFileMatch( ~"$fileName.*txt" ) { f ->
f.delete()
}
}
def createFile(String path,String fileName){
def tmp = File.createTempFile('Tem', '.txt',new File('D:\\workSpace\\groovy\\src\\'))
boolean flag = false
new File(path,fileName).eachLine(){ line->
line = line.trim();
if(isAuthLine(line) &&
line.indexOf("{")<0
){
if(line.startsWith("public")
&& line.indexOf('extends')>0){
flag = true
return
}
String[] dd = line.split('\\(')
if(dd.length > 1){
if(dd[1].indexOf(';') > 0){
flag = false
}
tmp.append('/** ' +dd[0] + ' ' + dd[1].substring(1,dd[1].length() -3) + ' */\n')
tmp.append(line)
tmp.append('\n')
}else{
tmp.append(line)
tmp.append('\n')
}
}
else{
if(flag){
tmp.append('\n')
}else{
tmp.append(line)
tmp.append('\n')
}
}
}
}
}
FileTest
最新推荐文章于 2025-01-20 09:51:01 发布