Here you can find the source of toPath(String... paths)
public static final String toPath(String... paths)
//package com.java2s; //License from project: Open Source License public class Main { public static final String toPath(String... paths) { StringBuilder builder = new StringBuilder(); for (String path : paths) { if (path.endsWith("/")) { path = path.substring(0, path.length() - 1); }// w w w .ja v a 2 s . co m if (path.startsWith("/")) { builder.append(path); } else { builder.append("/" + path); } } return builder.toString(); } }