/** * Given a parent path and a child node, create a combined full path * * @param parent the parent * @param child the child * @return full path */ public static String makePath(String parent, String child) { StringBuilder path = new StringBuilder(); joinPath(path, parent, child); return path.toString(); }
/** * Given a parent path and a list of children nodes, create a combined full path * * @param parent the parent * @param firstChild the first children in the path * @param restChildren the rest of the children in the path * @return full path */ public static String makePath(String parent, String firstChild, String... restChildren) { StringBuilder path = new StringBuilder(); joinPath(path, parent, firstChild); if ( restChildren == null ) { return path.toString(); } else { for ( String child : restChildren ) { joinPath(path, "", child); } return path.toString(); } }
/** * Given a parent path and a child node, create a combined full path * * @param parent the parent * @param child the child * @return full path */ public static String makePath(String parent, String child) { // 2 is the maximum number of additional path separators inserted int maxPathLength = nullableStringLength(parent) + nullableStringLength(child) + 2; // Avoid internal StringBuilder's buffer reallocation by specifying the max path length StringBuilder path = new StringBuilder(maxPathLength); joinPath(path, parent, child); return path.toString(); }