Here you can find the source of createPathOrNull(String pathString)
public static Path createPathOrNull(String pathString)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014 Bruno Medeiros and other Contributors. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* w ww . ja va 2 s . co m*/ * Bruno Medeiros - initial API and implementation *******************************************************************************/ import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; public class Main { /** @return a valid path, * or null if a valid path could not be created from given pathString. */ public static Path createPathOrNull(String pathString) { try { return Paths.get(pathString); } catch (InvalidPathException ipe) { return null; } } }