Java Path File Check nio isUNC(Path inputPath)

Here you can find the source of isUNC(Path inputPath)

Description

Test if a Path is UNC.

License

Open Source License

Parameter

Parameter Description
inputPath the path to check

Return

true if the passed in Path is UNC, false otherwise

Declaration

synchronized public static boolean isUNC(Path inputPath) 

Method Source Code

//package com.java2s;
/*/*  w  w w  . jav a  2s . com*/
 * Autopsy Forensic Browser
 *
 * Copyright 2011-2016 Basis Technology Corp.
 * Contact: carrier <at> sleuthkit <dot> org
 *
 * 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.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.nio.file.Path;

public class Main {
    private static final String UNC_PATH_START = "\\\\";

    /**
     * Test if a Path is UNC. It is considered UNC if it begins with \\
     *
     * @param inputPath the path to check
     *
     * @return true if the passed in Path is UNC, false otherwise
     */
    synchronized public static boolean isUNC(Path inputPath) {
        if (inputPath != null) {
            return isUNC(inputPath.toString());
        } else {
            return false;
        }
    }

    /**
     * Test if a String path is UNC. It is considered UNC if it begins with \\
     *
     * @param inputPath the String of the path to check
     *
     * @return true if the passed in Path is UNC, false otherwise
     */
    synchronized public static boolean isUNC(String inputPath) {
        if (inputPath != null) {
            return inputPath.startsWith(UNC_PATH_START);
        } else {
            return false;
        }
    }
}

Related

  1. isPictureFile(Path file)
  2. isRegularUsable(final Path pathToFile, final LinkOption... linkOption)
  3. isSame(Path expected, Path actual)
  4. isSameFile(Path path1, Path path2)
  5. isSteadyStateReached(Path integrationStepFile, double minStepAtEndOfStabilization)
  6. isUnix(Path path)
  7. isValidDirectory(String path)
  8. isValidFileType(Path filePath)
  9. isValidHomeDirectory(final Path path)