diff --git a/src/main/java/org/janelia/saalfeldlab/n5/N5Reader.java b/src/main/java/org/janelia/saalfeldlab/n5/N5Reader.java index b0df178b..164bb68f 100644 --- a/src/main/java/org/janelia/saalfeldlab/n5/N5Reader.java +++ b/src/main/java/org/janelia/saalfeldlab/n5/N5Reader.java @@ -331,4 +331,29 @@ public default String getGroupSeparator() { return "/"; } + + /** + * Creates a group path by concatenating all nodes with the node separator + * defined by {@link #getGroupSeparator()}. The string will not have a + * leading or trailing node separator symbol. + * + * @param nodes + * @return + */ + public default String groupPath(final String... nodes) { + + if (nodes == null || nodes.length == 0) + return ""; + + final String groupSeparator = getGroupSeparator(); + final StringBuilder builder = new StringBuilder(nodes[0]); + + for (int i = 1; i < nodes.length; ++i) { + + builder.append(groupSeparator); + builder.append(nodes[i]); + } + + return builder.toString(); + } }