У меня есть этот код, можно сделать, используя типично
private static final String FS = System.getProperty("file.separator");
JFileChooser folderChooser = new JFileChooser();
if (folderChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
String filename = folderChooser.getSelectedFile().getPath();
String[] recursivePaths = filename.split(FS);
TreePath treePath = null;
for (String part : recursivePaths) {
int row = (treePath == null ? 0 : treePaths.getRowForPath(treePath));
treePath = treePaths.getNextMatch(part, row, Position.Bias.Forward);
if (treePath == null) {
}
}
}
Но я хочу знать, возможно ли использовать Java 8 Stream, дополнительно
private static final String FS = System.getProperty("file.separator");
JFileChooser folderChooser = new JFileChooser();
if (folderChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
String filename = folderChooser.getSelectedFile().getPath();
String[] recursivePaths = filename.split(FS);
Stream.of(recursivePaths).forEach(partFile -> {
// Do something with FIRST, But How Discover?
// Do something with OTHERS
// Do something with LAST, But How Discover?
});
}