Last active
August 6, 2018 16:27
-
-
Save ksurendra/de1f1eb3d5c4803960d961e88e9f86c0 to your computer and use it in GitHub Desktop.
Example usage of Java Path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
List<TagBean> superCategories = new ArrayList<>(); | |
List<TagBean> categories = new ArrayList<>(); | |
List<TagBean> channels = new ArrayList<>(); | |
List<TagBean> shows = new ArrayList<>(); | |
String filePath = "/etc/tags/namespace/shows/super-category/category/channel/show/show-name" | |
Path path = Paths.get(filePath); | |
// Bucket: super-category | |
if (path.getNameCount() == 5) { // Level : super-category | |
superCategories.add(new TagBean("super-categories", ...)); | |
} | |
// Bucket: categories | |
if (path.getNameCount() == 6) { // Level : category | |
categories.add(new TagBean("categories", ...)); | |
} | |
// Bucket: channels | |
if (path.getNameCount() == 7) { // Level : channel | |
channels.add(new TagBean("channels", ...)); | |
} | |
// Bucket: shows | |
if (path.getNameCount() == 8) { // Level : shows | |
shows.add(new TagBean("shows", ...)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment