當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。