Here you can find the source of isValidDirectory(String path)
Parameter | Description |
---|---|
path | a parameter |
true
if the given path is a valid one; false
otherwise.
public static boolean isValidDirectory(String path)
//package com.java2s; /**/*from w ww . j a v a2s. co m*/ * Aptana Studio * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the GNU Public License (GPL) v3 (with exceptions). * Please see the license.html included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ import java.io.File; import java.io.IOException; public class Main { /** * A simple check that the directory path is a valid one for the current OS. The check does not test for existence * or write permissions, just for the path structure by using {@link File#getCanonicalPath()}. * * @param path * @return <code>true</code> if the given path is a valid one; <code>false</code> otherwise. */ public static boolean isValidDirectory(String path) { File file = new File(path); try { file.getCanonicalPath(); return true; } catch (IOException e) { return false; } } }