Java Path Combine combinePaths(String[] paths)

Here you can find the source of combinePaths(String[] paths)

Description

combine Paths

License

Open Source License

Declaration

public static String combinePaths(String[] paths) 

Method Source Code

//package com.java2s;
/*  This file is part of Openrouteservice.
 *
 *  Openrouteservice is free software; you can redistribute it and/or modify it under the terms of the 
 *  GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 
 *  of the License, or (at your option) any later version.
    //from www  .jav  a  2  s . com
 *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
 *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 *  See the GNU Lesser General Public License for more details.
    
 *  You should have received a copy of the GNU Lesser General Public License along with this library; 
 *  if not, see <https://www.gnu.org/licenses/>.  
 */

import java.io.File;

public class Main {
    public static String combinePaths(String[] paths) {
        if (paths.length == 0) {
            return "";
        }

        File combined = new File(paths[0]);

        int i = 1;
        while (i < paths.length) {
            combined = new File(combined, paths[i]);
            ++i;
        }

        return combined.getPath();
    }
}

Related

  1. combinePath(String... paths)
  2. combinePaths(final String path, final String... furtherPaths)
  3. combinePaths(String root, String... more)
  4. combinePaths(String root, String... more)
  5. combinePaths(String... items)