Java Path File Name nio jobNameFromPath(Path path)

Here you can find the source of jobNameFromPath(Path path)

Description

Get job name without file extension

License

Open Source License

Parameter

Parameter Description
path Path

Return

String

Declaration

public static String jobNameFromPath(Path path) 

Method Source Code

//package com.java2s;
/**/*from www . j  ava2  s . c o m*/
 * Copyright 2015 LinkedIn Corp. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 */

import java.nio.file.Path;

public class Main {
    /**
     * Get job name without file extension
     * @param path Path
     * @return String
     */
    public static String jobNameFromPath(Path path) {
        return jobNameFromFileName(path.getFileName().toString());
    }

    /**
     * Get job name without file extension
     * @param filename String
     * @return String
     */
    public static String jobNameFromFileName(String filename) {
        return filename.substring(0, filename.lastIndexOf('.'));
    }
}

Related

  1. getUniqueFileInDirectory(Path dir, String name)
  2. inheritGwtModule(Path path, String inheritableModuleLogicalName)
  3. initializePath(String... envVarNames)
  4. isExecutableOnPath(String execName)
  5. isHiddenName(Path path)
  6. listDocTypeName(Path path)
  7. makeUnique(Path basePath, String baseName)
  8. pathToPackageName(Path path)
  9. readFileFromPath(String filename)