mardi 17 mars 2015

JAVA8 lambda how to make code sample


Vote count:

0




i think my code need to promote, i use object "allSummaryTSTLog" both in stream().filter() and .map(), so i have to new twice, so do with object named by "filter" in line 2 :



public static List<Test> ParserPath(List<String> allLogPath) {

FilenameFilter filter = new MyFilter("Summary_TSTLog");

return allLogPath.parallelStream().filter(path -> {
File testPath = new File(path);

if(!testPath.isDirectory()){
MyLog.log.info("test path : [" + path + "] is not exist, continue");
return false;
}

File[] allSummaryTSTLog = testPath.listFiles(filter);
if(allSummaryTSTLog == null || allSummaryTSTLog.length == 0){
MyLog.log.info("test path : [" + path + "] has no Summary_TSTLog files");
return false;
}
return true;
}).map(path -> {
String[] nameTempStr = path.split("\\\\");
String testName = nameTempStr[nameTempStr.length - 1];

File[] allSummaryTSTLog = new File(path).listFiles(filter);

return new Test(testName, Arrays.asList(allSummaryTSTLog));
}).collect(Collectors.toList());
}


here is question: how can i new once object allSummaryTSTLog and named by "filter"? thanks advance.



asked 49 secs ago

ming

47






JAVA8 lambda how to make code sample

Aucun commentaire:

Enregistrer un commentaire