Java List Join joinRelativePath(List components)

Here you can find the source of joinRelativePath(List components)

Description

Construct a relative path from the given components

License

Open Source License

Parameter

Parameter Description
components a parameter

Return

relative path

Declaration

public static String joinRelativePath(List<String> components) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Arrays;
import java.util.List;

public class Main {
    /**//from ww w.ja  v  a  2  s .c  o m
     * Construct a relative path from the given components
     * @param components
     * @return relative path
     */
    public static String joinRelativePath(List<String> components) {
        StringBuilder builder = new StringBuilder();
        for (String component : components) {
            if (builder.length() > 0)
                builder.append('/');
            builder.append(component);
        }

        return builder.toString();
    }

    /**
     * Vararg version of joinRelativePath
     * @param components
     * @return relative path
     */
    public static String joinRelativePath(String... components) {
        return joinRelativePath(Arrays.asList(components));
    }
}

Related

  1. joinLists(List... list)
  2. joinListToString(List lsStr, String sSeparator)
  3. joinLong(List lst, String prefix)
  4. joinNiceString(List strings)
  5. joinRecords(List first, List second, String key)
  6. joinSegments(List segments, int startIndex, int endIndex)
  7. joinString(java.util.List values, String delimiter)
  8. joinString(List array, String symbol)
  9. joinString(List objs, String separator)