本文整理汇总了Java中org.codehaus.plexus.util.FileUtils.fileExists方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.fileExists方法的具体用法?Java FileUtils.fileExists怎么用?Java FileUtils.fileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.util.FileUtils
的用法示例。
在下文中一共展示了FileUtils.fileExists方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWeaveSourceFiles
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Based on a set of weavedirs returns a set of all the files to be weaved.
*
* @return
* @throws MojoExecutionException
*/
public static Set<String> getWeaveSourceFiles( String[] weaveDirs )
throws MojoExecutionException
{
Set<String> result = new HashSet<String>();
for ( int i = 0; i < weaveDirs.length; i++ )
{
String weaveDir = weaveDirs[i];
if ( FileUtils.fileExists( weaveDir ) )
{
try
{
result.addAll( FileUtils.getFileNames( new File( weaveDir ), "**/*.class", DEFAULT_EXCLUDES, true ) );
}
catch ( IOException e )
{
throw new MojoExecutionException( "IO Error resolving weavedirs", e );
}
}
}
return result;
}
示例2: readBuildConfigFile
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Reads a build config file, and returns the List of all compiler arguments.
*
* @param fileName the filename of the argfile
* @param outputDir the build output area
* @return
* @throws IOException
*/
public static List<String> readBuildConfigFile( String fileName, File outputDir )
throws IOException
{
List<String> arguments = new ArrayList<String>();
File argFile = new File( outputDir, fileName );
if ( FileUtils.fileExists( argFile.getAbsolutePath() ) )
{
FileReader reader = new FileReader( argFile );
BufferedReader bufRead = new BufferedReader( reader );
String line = null;
do
{
line = bufRead.readLine();
if ( null != line )
{
arguments.add( line );
}
}
while ( null != line );
}
return arguments;
}
示例3: createLocalConfdProcessor
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private static Processor createLocalConfdProcessor(Properties properties) throws ProcessorCreationException {
String binaryPathProperty = properties.getProperty("binary.path");
if (StringUtils.isEmpty(binaryPathProperty)) {
throw new ProcessorCreationException("processor " + LOCAL_CONFD_PROCESSOR +
"the binary.path property is missing.");
}
// check if confd is present
if (!FileUtils.fileExists(binaryPathProperty)) {
throw new ProcessorCreationException("processor " + LOCAL_CONFD_PROCESSOR + " confd binary " +
binaryPathProperty + " does not exists");
}
return new LocalConfdProcessorImpl(binaryPathProperty);
}
示例4: getBuildFilesForSourceDirs
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Based on a set of sourcedirs, apply include and exclude statements and
* returns a set of all the files to be compiled and weaved.
*
* @param sourceDirs
* @param includes
* @param excludes
* @return
* @throws MojoExecutionException
*/
public static Set<String> getBuildFilesForSourceDirs( List<String> sourceDirs, String[] includes, String[] excludes )
throws MojoExecutionException
{
Set<String> result = new LinkedHashSet<String>();
for ( String sourceDir : sourceDirs )
{
try
{
if ( FileUtils.fileExists( sourceDir ) )
{
result.addAll( FileUtils
.getFileNames( new File( sourceDir ),
( null == includes || 0 == includes.length ) ? DEFAULT_INCLUDES
: getAsCsv( includes ),
( null == excludes || 0 == excludes.length ) ? DEFAULT_EXCLUDES
: getAsCsv( excludes ), true ) );
}
}
catch ( IOException e )
{
throw new MojoExecutionException( "IO Error resolving sourcedirs", e );
}
}
// We might need to check if some of these files are already included through the weaveDirectories.
return result;
}
示例5: resolveIncludeExcludeString
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* Helper method to find all .java or .aj files specified by the
* includeString. The includeString is a comma separated list over files, or
* directories relative to the specified basedir. Examples of correct
* listings
*
* <pre>
* src/main/java/
* src/main/java
* src/main/java/com/project/AClass.java
* src/main/java/com/project/AnAspect.aj
* src/main/java/com/project/AnAspect.java
* </pre>
*
* @param input
* @param basedir the baseDirectory
* @return a list over all files inn the include string
* @throws IOException
*/
protected static Set<String> resolveIncludeExcludeString( String input, File basedir )
throws MojoExecutionException
{
Set<String> inclExlSet = new LinkedHashSet<String>();
try
{
if ( null == input || input.trim().equals( "" ) )
{
return inclExlSet;
}
String[] elements = input.split( "," );
if ( null != elements )
{
for ( int i = 0; i < elements.length; i++ )
{
String element = elements[i];
if ( element.endsWith( ".java" ) || element.endsWith( ".aj" ) )
{
inclExlSet.addAll( FileUtils.getFileNames( basedir, element, "", true ) );
}
else
{
File lookupBaseDir = new File( basedir, element );
if ( FileUtils.fileExists( lookupBaseDir.getAbsolutePath() ) )
{
inclExlSet.addAll( FileUtils.getFileNames( lookupBaseDir, DEFAULT_INCLUDES, "",
true ) );
}
}
}
}
}
catch ( IOException e )
{
throw new MojoExecutionException( "Could not resolve java or aspect sources to compile", e );
}
return inclExlSet;
}
示例6: testBuildConfigFile
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
*
* @throws Exception
*/
public void testBuildConfigFile()
{
final File baseDir = new File(".");
final String fileName = "test.lst";
final String fileAbsolutePath = baseDir.getAbsolutePath() + File.separator + fileName;
List args = new ArrayList();
args.add("-classpath");
args.add("a:b:c");
args.add("-showWeaveInfo");
args.add("/home/aspectj/AFile");
args.add("/home/aspectj/AnotherFile");
try
{
AjcHelper.writeBuildConfigToFile(args,fileName,baseDir);
assertTrue("Config file not written to disk",FileUtils.fileExists(fileAbsolutePath));
List readArgs = AjcHelper.readBuildConfigFile(fileName,baseDir);
assertEquals(args,readArgs);
} catch (Exception e)
{
fail("Unexpected exception: " + e.toString());
if (FileUtils.fileExists(fileAbsolutePath))
{
FileUtils.fileDelete(fileAbsolutePath);
}
}
}
示例7: getMetaData
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private Metadata getMetaData(String xmlMetaData) throws XmlMappingException, IOException, ClassNotFoundException, SQLException {
if (isNotBlank(xmlMetaData)) {
return getMetadataFromFile(xmlMetaData);
} else if (FileUtils.fileExists(DEFAULT_XML_METADATA)) {
return getMetadataFromFile(DEFAULT_XML_METADATA);
} else {
return getMetadataFromDatabase();
}
}
示例8: getCelerio
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private Celerio getCelerio(String xmlConfiguration) {
Celerio celerio;
if (FileUtils.fileExists(xmlConfiguration)) {
celerio = getCelerioConfigurationFromFile(xmlConfiguration);
} else {
getLog().warn("****** The Celerio configuration file [" + xmlConfiguration + "] could not be found. Will use default empty configuration ******");
celerio = new Celerio();
}
overridePacksAndModules(celerio);
return celerio;
}
示例9: overridePacksAndModules
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
* For convenience (multi module, springfuse, etc...) template packs and modules may be in a separate file... we process this file if it exists.
*
* @param celerio
*/
private void overridePacksAndModules(Celerio celerio) {
String filename = xmlTemplatePacksOverride;
if (!FileUtils.fileExists(filename)) {
return;
}
getLog().info("Overriding configuration with " + filename);
CelerioLoader celerioLoader = context.getBean(CelerioLoader.class);
try {
Configuration configuration = celerioLoader.load(filename).getConfiguration();
// override celerioContext
CelerioTemplateContext ctc = configuration.getCelerioTemplateContext();
if (ctc != null) {
celerio.getConfiguration().setCelerioTemplateContext(ctc);
}
// override packs
List<Pack> newPacks = configuration.getPacks();
if (newPacks != null && !newPacks.isEmpty()) {
celerio.getConfiguration().setPacks(newPacks);
}
// override modules
List<Module> newModules = configuration.getModules();
if (newModules != null && !newModules.isEmpty()) {
celerio.getConfiguration().setModules(newModules);
}
} catch (Exception e) {
throw new RuntimeException("Could not do override: ["+ filename + "]", e);
}
}
示例10: execute
import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
*
*/
public void execute() throws MojoExecutionException, MojoFailureException
{
if ( puXMLFile == null || !FileUtils.fileExists( puXMLFile ) )
{
throw new MojoExecutionException( "missing pu.xml file" );
}
if ( warFile == null || !FileUtils.fileExists( warFile ) )
{
throw new MojoExecutionException( "missing war file" );
}
try
{
String puTargetDir = serverDirectory + File.separator + "META-INF" + File.separator + "spring";
String libTargetDir = serverDirectory + File.separator + "lib";
FileUtils.mkdir( serverDirectory );
FileUtils.mkdir( puTargetDir );
FileUtils.mkdir( libTargetDir );
FileUtils.copyFileToDirectory( new File( puXMLFile ), new File( puTargetDir ) );
FileUtils.copyFileToDirectory( new File( warFile ), new File( serverDirectory ) );
for (Iterator artifactIterator = pluginArtifacts.iterator(); artifactIterator.hasNext();)
{
Artifact artifact = (Artifact) artifactIterator.next();
if (artifact.getGroupId().equals("org.mortbay.jetty") )
{
FileUtils.copyFileToDirectory( artifact.getFile().getPath(), libTargetDir );
}
}
jarArchiver.addDirectory( new File(serverDirectory) );
jarArchiver.setDestFile( new File(artifactName) );
jarArchiver.createArchive();
}
catch ( IOException ioe )
{
throw new MojoExecutionException( "unable to assemble",ioe );
}
catch ( ArchiverException ae )
{
throw new MojoExecutionException( "unable to assembly jar", ae );
}
}