X Tutup
Skip to content

Commit 8998cbc

Browse files
committed
refactor code to java 8 streams api
1 parent e1fdf30 commit 8998cbc

File tree

1 file changed

+7
-19
lines changed
  • biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite

1 file changed

+7
-19
lines changed

biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite/Dataset.java

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
import java.nio.file.Files;
3030
import java.nio.file.StandardCopyOption;
3131
import java.util.ArrayList;
32+
import java.util.Arrays;
3233
import java.util.List;
34+
import java.util.stream.Collectors;
35+
import java.util.stream.Stream;
3336

3437
/**
3538
* Phosphosite is available under the PhosphoSitePlus® is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License and is freely available for non-commercial purposes from
@@ -76,27 +79,12 @@ private String[] getRemoteFiles(){
7679
}
7780

7881
public File[] getLocalFiles(){
79-
8082
String[] rfiles = getRemoteFiles();
81-
82-
8383
File dir = getLocalDir();
84-
85-
List<File> files = new ArrayList<File>();
86-
for ( String f : rfiles) {
87-
88-
89-
int slashIndex = f.lastIndexOf("/");
90-
91-
String fileName = f.substring(slashIndex);
92-
93-
File localFile = new File(dir+"/" + fileName);
94-
95-
if ( localFile.exists()){
96-
files.add(localFile);
97-
}
98-
99-
}
84+
List<File> files = Arrays.stream(rfiles).map(remoteFileName -> remoteFileName.substring(remoteFileName.lastIndexOf("/")))
85+
.map(localFile -> new File(dir+"/"+localFile))
86+
.filter(file -> file.exists())
87+
.collect(Collectors.toList());
10088

10189
return files.toArray(new File[files.size()]);
10290
}

0 commit comments

Comments
 (0)
X Tutup