Here you can find the source of isValidPath(String path)
Parameter | Description |
---|---|
path | A string representing the file path. Cannot be null. |
public static boolean isValidPath(String path)
//package com.java2s; //License from project: Open Source License import java.nio.file.InvalidPathException; import java.nio.file.Paths; public class Main { /**/*www . j a va 2s .co m*/ * Returns true if {@code path} can be converted into a {@code Path} via {@link Paths#get(String)}, * otherwise returns false. * @param path A string representing the file path. Cannot be null. */ public static boolean isValidPath(String path) { try { Paths.get(path); } catch (InvalidPathException ipe) { return false; } return true; } }