本文整理汇总了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;
}
示例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;
}
示例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;
}
}
}
}
示例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;
}
}
}