前序递归列出所有文件, 列出文件名匹配通配符的文件

如 ("/a/b/hello.txt", "he*") 将被返回
183300
public static List<File> listFileWithWildcardFileName(final File rootDir, final String fileNamePattern) {
		return Files.fileTreeTraverser().preOrderTraversal(rootDir).filter(new WildcardFileNameFilter(fileNamePattern))
				.toList();
	}
788780
private String extractFileName(Part part) {
		String disposition = part.getHeader("Content-Disposition");
		if (disposition == null)
			return null;
		Matcher matcher = FILENAME_PATTERN.matcher(disposition);
		if (!matcher.find())
			return null;
		return matcher.group(1);
	}
110495
def do_hello(self, sin, sout, name=None):
        
        name = '' if name is None else '/' + name
        r = requests.get('http://localhost:8090/hello' + name)
        sout.write(r.text + '\n')
722345
function onlyCreateFrom(summaryFilePath){
    /**
     * @var {string} agm 额外需要写入文件的内容。
     */
    var agm = arguments[1];
    var ostpye = require('os').type;
    if(fs.existsSync(summaryFilePath)){
        var rl = readline.createInterface({
            input: fs.createReadStream(summaryFilePath)
        });
        rl.on('line', function (line) {
            var title = line.match(/\[[\s\S]*\]\B/g);
            title = '# ' + title[0].replace(/^\[|\]$/g, "");
            var filePath = line.match(/\]\([\w\W]*\)\B/g);
            var fileName = filePath[0].replace(/[\]\(\)]/g,"");
            if(ostpye=="Windows_NT" && agm!==undefined){
                var wData = title + '\r\n'+agm;
                nNmc.fs_wfSync(fileName,wData,false)
            }else if(ostpye !=="Windows_NT" && agm!==undefined){
                var wData = title + '\n'+agm;
                nNmc.fs_wfSync(fileName,wData,false)
            }else{
                nNmc.fs_wfSync(fileName,title,false)
            }
            console.log(`${chalk.yellow('summarybuilder:  ')}`+fileName+'.........created!');
        });
    }else{
        console.log(`${chalk.yellow('summarybuilder:  ')}找不到文件(No such file)--`+summaryFilePath)
    }
}
764151
function fillFileTree (fileTree, fileList) {
  let extname

  fileList.forEach(filePath => {
    extname = path.extname(filePath)
    const linters = Object.keys(linterSuffix)

    const match = linters.some(linterName => {
      if (linterSuffix[linterName].includes(extname)) {
        fileTree[linterName].push(filePath)
        return true
      }

      return false
    })

    // 没有匹配到特定的 linter，则分配给所有 linter
    if (!match) {
      linters.forEach(linterName => {
        fileTree[linterName].push(filePath)
      })
    }
  })

  return fileTree
}
801909
def wrtxt_hier(self, fout_txt):
        """"""
        with open(fout_txt, 'wb') as prt:
            self.prt_hier(prt)
            print("  WROTE: {TXT}".format(TXT=fout_txt))
324533
private static void extractText(Path file, BufferedWriter writer, String separator, boolean includePhrase){
        try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file.toFile()),"utf-8"));){
            String line;
            while( (line = reader.readLine()) != null ){
                //去除首尾空白字符
                line = line.trim();
                //忽略空行
                if(!"".equals(line)){
                    //词和词之间以空格隔开
                    String[] words = line.split("\\s+");
                    if(words == null){
                        //忽略不符合规范的行
                        continue;
                    }
                    StringBuilder phrase = new StringBuilder();
                    int phraseCount=0;
                    boolean find=false;
                    for(String word : words){
                        String[] attr = word.split("/");
                        if(attr == null || attr.length < 1){
                            //忽略不符合规范的词
                            continue;
                        }
                        if(attr[0].trim().startsWith("[")){
                            find = true;
                        }                        
                        //去掉[和]
                        String item = attr[0].replace("[", "").replace("]", "").trim();
                        writer.write(item+separator);
                        if(find){
                            phrase.append(item);
                            phraseCount++;
                        }
                        //短语标注错误
                        if(phraseCount > 10){
                            find = false;
                            phraseCount = 0;
                            phrase.setLength(0);
                        }
                        if(find && attr.length > 1 && attr[1].trim().endsWith("]")){
                            find = false;
                            if(includePhrase){
                                writer.write(phrase.toString()+separator);
                            }
                            phrase.setLength(0);
                        }
                        //词数目
                        WORD_COUNT.incrementAndGet();
                        //字符数目
                        CHAR_COUNT.addAndGet(item.length());
                    }
                    //换行
                    writer.write("\n");
                }
            }
        }catch(Exception e){
            LOGGER.info("从语料库 "+file+" 中抽取文本失败：", e);
        }        
    }
1011235
private function randomFileName()
        {
            if ($this->randomNameType == 1)        // 生成时间格式文件名
            {
                date_default_timezone_set('PRC');  //设置时区
                
                $date     = date($this->randomLength);
                $fileName = $date . "_" . mt_rand(10000, 99999);
            }
            elseif ($this->randomNameType == 2)    // 生成随机字符文件名
            {
                $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
                $max   = strlen($chars) - 1;
                mt_srand((double)microtime() * 1000000);
                
                for($i = 0; $i < $this->randomLength; $i++)
                {
                    $fileName .= $chars[mt_rand(0, $max)];
                }
            }
            else
            {
                $fileName = '';
            }

            return $fileName;
        }
909187
public void tagFile(String input,String output,String sep){
		String s = tagFile(input,"\n");
		try {
			OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(
					output), "utf-8");
			BufferedWriter bw = new BufferedWriter(writer);
			bw.write(s);
			bw.close();
		} catch (Exception e) {
			System.out.println("写输出文件错误");
			e.printStackTrace();
		}
	}
1203202
def _getPFilename(self,native,prompt):
        
        return self.get(native=native,prompt=prompt)
134569
def filesfile_string(self):
        """"""
        lines = []
        app = lines.append

        #optic.in     ! Name of input file
        #optic.out    ! Unused
        #optic        ! Root name for all files that will be produced
        app(self.input_file.path)                           # Path to the input file
        app(os.path.join(self.workdir, "unused"))           # Path to the output file
        app(os.path.join(self.workdir, self.prefix.odata))  # Prefix for output data

        return "\n".join(lines)
934402
def getFilename(name):
    """"""
    # first replace all illegal chars
    name = re.sub(r"[^0-9a-zA-Z_\-\.]", "_", name)
    # then remove double dots and underscores
    while ".." in name:
        name = name.replace('..', '.')
    while "__" in name:
        name = name.replace('__', '_')
    # remove a leading dot or minus
    if name.startswith((".", "-")):
        name = name[1:]
    return name
988997
def askopenfilename(**kwargs):
    """"""
    try:
        from Tkinter import Tk
        import tkFileDialog as filedialog
    except ImportError:
        from tkinter import Tk, filedialog
    root = Tk()
    root.withdraw()
    root.update()
    filenames = filedialog.askopenfilename(**kwargs)
    root.destroy()
    return filenames
942267
function getFileName(path) {
		var re = /([\w\.\-]+)$/i;
		var m = re.exec(path);
		return m ? m[1] : '';
	}
995556
function(stdout, next) {
				var lines = stdout.split("\n");
				var filenames = _.transform(lines, function(result, line) {
					var status = line.slice(0, 2);
					if (regExp.test(status)) {
						result.push(_.last(line.split(' ')));
					}
				});

				next(null, filenames);
			}
484811
function getFileNames(path, extension)
{
    var docPath = __dirname + '/' + path;
    var fileNames = [];
    var findPattern = new RegExp("." + extension + "$");
    var replacePattern = new RegExp("." + extension + "$","g");
    fs.readdirSync( docPath ).forEach( function(fileName ) {
        if( fileName.match( findPattern ) ) {
            fileNames.push( fileName.replace( replacePattern, "" ) );
        }
    });

    verbose && console.log('Read "' + extension + '" files from ' + docPath );

    return fileNames;
}
1247028
public String getFileNameWithoutSuffix( File texFile )
    {
        String nameTexFile = texFile.getName();
        String namePrefixTexFile = nameTexFile.substring( 0, nameTexFile.lastIndexOf( "." ) );
        return namePrefixTexFile;
    }