Here you can find the source of checkDirectoryInWorkspace(String directoryName)
Parameter | Description |
---|---|
directoryName | a parameter |
public static boolean checkDirectoryInWorkspace(String directoryName)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2008 Symbian Software Limited and others. * 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 . j a v a 2 s . c o m * Bala Torati (Symbian) - Initial API and implementation * IBM Corporation *******************************************************************************/ import java.io.File; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; public class Main { /** * Check whether there is a directory existing in present workspace, with * the given name. * * @param directoryName * @return true, if directory exists. * * @since 4.0 */ public static boolean checkDirectoryInWorkspace(String directoryName) { boolean retVal = false; File file = null; try { file = new File(getWorkspacePath() + directoryName); } catch (Exception exp) { } if ((file != null) && (file.exists()) && (file.isDirectory())) { retVal = true; } return retVal; } /** * This method returns the workspace path present in the workspace * * @return String Example : file:/C:/eclipse/workspace/ * * @since 4.0 */ public static IPath getWorkspacePath() { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); IPath workSpacePath = new Path(root.getLocation().toString() + File.separator); return workSpacePath; } }