Java Path Combine combinePath(String... paths)

Here you can find the source of combinePath(String... paths)

Description

Combine the arguments into a complete file path

License

Open Source License

Parameter

Parameter Description
paths a parameter

Return

The file path

Declaration

public static String combinePath(String... paths) 

Method Source Code

//package com.java2s;
/*----------------------------------------------------------------------------- 
 * GDSC SMLM Software// ww w.  j av  a 2  s.c o m
 * 
 * Copyright (C) 2016 Alex Herbert
 * Genome Damage and Stability Centre
 * University of Sussex, UK
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *---------------------------------------------------------------------------*/

import java.io.File;

public class Main {
    /**
     * Combine the arguments into a complete file path
     * 
     * @param paths
     * @return The file path
     */
    public static String combinePath(String... paths) {
        File file = new File(paths[0]);

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

        return file.getPath();
    }
}

Related

  1. combinePath(String parent, String name)
  2. combinePath(String part0, String... parts)
  3. combinePath(String path1, String path2)
  4. combinePath(String path1, String path2, String pathSeperator)
  5. combinePath(String... paths)
  6. combinePaths(final String path, final String... furtherPaths)
  7. combinePaths(String root, String... more)
  8. combinePaths(String root, String... more)
  9. combinePaths(String... items)