Java Path File Extention nio getPath(String outputDir, String qualifiedFilename, String fileextension)

Here you can find the source of getPath(String outputDir, String qualifiedFilename, String fileextension)

Description

get Path

License

Open Source License

Declaration

public static Path getPath(String outputDir, String qualifiedFilename,
            String fileextension) 

Method Source Code

//package com.java2s;
/*//from www.  j a v a2s  .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.FileSystems;
import java.nio.file.Path;

public class Main {
    public static Path getPath(String outputDir, String qualifiedFilename,
            String fileextension) {
        String[] pathParts = qualifiedFilename.split("\\.");
        pathParts[pathParts.length - 1] = pathParts[pathParts.length - 1]
                + "." + fileextension;
        return FileSystems.getDefault().getPath(outputDir, pathParts);
    }

    /**
     * @param qn QualifiedName (without fileExtesion) or FullQualifiedName (with fileExtesion)
     * @return
     */
    public static String getPath(String qn) {
        String path = "";
        if (qn.contains(".")) {
            path = qn.substring(0, qn.lastIndexOf("."));
        }
        return path;
    }
}

Related

  1. getFileNameWithoutExtension(String filePath)
  2. getFilesList(Path directory, Set extensions)
  3. getFullNameWithoutExtension(Path f)
  4. getLeafName(Path path, boolean includeExtension)
  5. getListOfFilesByExtension(Path directoryPath, Set extensions)
  6. getTransformedOutputPath(Path input, String compressExtension, String outputDir)
  7. hasExtensionIgnoreCase(Path path, String ext)
  8. insertSuffixBeforeExtension(String path, String suffix)
  9. listFile(final String path, final String extension)