当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.fileAppend方法代码示例

本文整理汇总了Java中org.codehaus.plexus.util.FileUtils.fileAppend方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.fileAppend方法的具体用法?Java FileUtils.fileAppend怎么用?Java FileUtils.fileAppend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.plexus.util.FileUtils的用法示例。


在下文中一共展示了FileUtils.fileAppend方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execution

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Override
protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) {
    File fileToBeModified = getAbsoluteFile(transformedAppFolder, transformationContext);

    if (!fileToBeModified.exists()) {
        // TODO Should this be done as pre-validation?
        FileNotFoundException ex = new FileNotFoundException("File to be modified has not been found");
        return TOExecutionResult.error(this, ex);
    }

    TOExecutionResult result = null;

    try {
        FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), EolHelper.findEolDefaultToOs(fileToBeModified));
        FileUtils.fileAppend(fileToBeModified.getAbsolutePath(), newLine);
        String details =  "A new line has been added to file " + getRelativePath(transformedAppFolder, fileToBeModified);
        result = TOExecutionResult.success(this, details);
    } catch (IOException e) {
        result = TOExecutionResult.error(this, e);
    }

    return result;
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:24,代码来源:AddLine.java

示例2: addProperty

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private TOExecutionResult addProperty(File transformedAppFolder, TransformationContext transformationContext) {
    File fileToBeChanged = getAbsoluteFile(transformedAppFolder, transformationContext);
    TOExecutionResult result;
    try {
        String[] propArray = {propertyName, propertyValue};
        String propertyKeyValue = "%s = %s";
        String propertyToBeAdded = String.format(propertyKeyValue, propArray);
        FileUtils.fileAppend(fileToBeChanged.getAbsolutePath(), EolHelper.findEolDefaultToOs(fileToBeChanged));
        FileUtils.fileAppend(fileToBeChanged.getAbsolutePath(), propertyToBeAdded);
        String details = String.format("Property '%s' has been added and set to '%s' at '%s'", propertyName, propertyValue, getRelativePath());
        result = TOExecutionResult.success(this, details);
    } catch (IOException e) {
        result = TOExecutionResult.error(this, e);
    }
    return result;
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:17,代码来源:AddProperty.java

示例3: playActions

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public void playActions() throws Exception {
  for (FileSystemAction action : actions) {
    if (action.kind == ENTRY_CREATE) {
      FileUtils.fileWrite(action.path.toFile(), action.content);
    } else if (action.kind == ENTRY_MODIFY) {
      FileUtils.fileAppend(action.path.toFile().getAbsolutePath(), action.content);
      action.path.toFile().setLastModified(new Date().getTime());
    } else if (action.kind == ENTRY_DELETE) {
      action.path.toFile().delete();
    } else {
      switch (action.myType) {
        case WAIT:
          try {
            Thread.sleep(action.millis);
          } catch (InterruptedException e) {
          }
          break;
        case MKDIR:
          if (!action.path.toFile().exists()) {
            action.path.toFile().mkdirs();
          }
          break;
        case COUNTABLE:
        case NOOP:
          break;
      }
    }
  }
}
 
开发者ID:takari,项目名称:directory-watcher,代码行数:30,代码来源:FileSystem.java

示例4: logLine

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
protected void logLine( boolean error, String line )
{
    if ( logOutput )
    {
        if ( error )
        {
            getLog().error( line );
        }
        else
        {
            getLog().info( line );
        }
    }
    if ( outputFile != null && !outputFileError )
    {
        try
        {
            FileUtils.fileAppend( outputFile.getAbsolutePath(), outputEncoding,
                                  error ? "> " + line + System.getProperty( "line.separator" )
                                                  : line + System.getProperty( "line.separator" ) );
        }
        catch ( IOException e )
        {
            getLog().error( "Cannot send output to " + outputFile, e );
            outputFileError = true;
        }
    }
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:29,代码来源:AbstractVersionsDisplayMojo.java


注:本文中的org.codehaus.plexus.util.FileUtils.fileAppend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。