Java Path File Name nio getQualifiedName(String outputDir, Path path)

Here you can find the source of getQualifiedName(String outputDir, Path path)

Description

Returns a dot separated name of the file represented by the given path without its fileextension Example: outputdir is /a/b and path represents /a/b/c/d/e.txt returns "c.d.e"

License

Open Source License

Parameter

Parameter Description
outputDir a parameter
path a parameter

Declaration

public static String getQualifiedName(String outputDir, Path path) 

Method Source Code

//package com.java2s;
/*/*from  w w  w . j a  v a  2s  . c  o  m*/
 * ******************************************************************************
 * MontiCore Language Workbench
 * Copyright (c) 2015, MontiCore, All rights reserved.
 *
 * This project 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 3.0 of the License, or (at your option) any later version.
 * 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 project. If not, see <http://www.gnu.org/licenses/>.
 * ******************************************************************************
 */

import java.nio.file.Path;

public class Main {
    /** Returns a dot separated name of the file represented by the given path without its fileextension
     *  Example: outputdir is /a/b and path represents /a/b/c/d/e.txt
     *  returns "c.d.e"
     * 
     * @param outputDir
     * @param path
     * @return
     */
    public static String getQualifiedName(String outputDir, Path path) {
        StringBuilder qualifiedName = new StringBuilder(path.getName(0)
                .toString());

        for (int i = 1; i < path.getNameCount() - 1; i++) {
            qualifiedName.append(".");
            qualifiedName.append(path.getName(i));
        }
        if (path.getFileName() != null) {
            String[] seperatedFileName = path.getFileName().toString()
                    .split("\\.");
            qualifiedName.append("." + seperatedFileName[0]);
        }
        return qualifiedName.toString();
    }
}

Related

  1. getPathProperty(Properties props, String propName)
  2. getPaths(Path dir, String fileNames)
  3. getPrefix(final Path file, final int filenameSuffixLength)
  4. getPrintWriter(String className, String flushPath)
  5. getProvenanceLogFiles(final String baseName, final Collection allProvenanceLogs)
  6. getRelativePathFile(String fileName)
  7. getRelativePathName(Path root, Path path)
  8. getResourcePath(Class resourceClass, String resourceName)
  9. getResourceRootPath(Class resourceClass, String resourceName)