本文整理了Java中org.apache.maven.shared.utils.io.FileUtils.fileWrite()
方法的一些代码示例,展示了FileUtils.fileWrite()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.fileWrite()
方法的具体详情如下:
包路径:org.apache.maven.shared.utils.io.FileUtils
类名称:FileUtils
方法名:fileWrite
[英]Writes data to a file. The file will be created if it does not exist.
[中]将数据写入文件。如果文件不存在,将创建该文件。
代码示例来源:origin: fabric8io/docker-maven-plugin
public static void storeTimestamp(File tsFile, Date buildDate) throws MojoExecutionException {
try {
if (tsFile.exists()) {
tsFile.delete();
}
File dir = tsFile.getParentFile();
if (!dir.exists()) {
if (!dir.mkdirs()) {
throw new MojoExecutionException("Cannot create directory " + dir);
}
}
FileUtils.fileWrite(tsFile, StandardCharsets.US_ASCII.name(), Long.toString(buildDate.getTime()));
} catch (IOException e) {
throw new MojoExecutionException("Cannot create " + tsFile + " for storing time " + buildDate.getTime(),e);
}
}
代码示例来源:origin: org.apache.maven.shared/maven-shared-utils
/**
* Writes data to a file. The file will be created if it does not exist.
* Note: the data is written with platform encoding
*
* @param fileName The path of the file to write.
* @param data The content to write to the file.
* @throws IOException if any
*/
public static void fileWrite( @Nonnull String fileName, @Nonnull String data )
throws IOException
{
fileWrite( fileName, null, data );
}
代码示例来源:origin: org.apache.maven.shared/maven-shared-utils
/**
* Writes data to a file. The file will be created if it does not exist.
*
* @param fileName The path of the file to write.
* @param encoding The encoding of the file.
* @param data The content to write to the file.
* @throws IOException if any
*/
public static void fileWrite( @Nonnull String fileName, @Nullable String encoding, @Nonnull String data )
throws IOException
{
File file = new File( fileName );
fileWrite( file, encoding, data );
}
代码示例来源:origin: org.apache.maven.shared/maven-verifier
/**
* Writes a text file with the specified contents. The contents will be encoded using UTF-8.
*
* @param path The path to the file, relative to the base directory, must not be <code>null</code>.
* @param contents The contents to write, must not be <code>null</code>.
* @throws IOException If the file could not be written.
* @since 1.2
*/
public void writeFile( String path, String contents )
throws IOException
{
FileUtils.fileWrite( new File( getBasedir(), path ).getAbsolutePath(), "UTF-8", contents );
}
代码示例来源:origin: org.apache.maven.plugins/maven-install-plugin
/**
* Installs a checksum for the specified file.
*
* @param installedFile The base path from which the path to the checksum files is derived by appending the given
* file extension, must not be <code>null</code>.
* @param ext The file extension (including the leading dot) to use for the checksum file, must not be
* <code>null</code>.
* @param checksum the checksum to write
* @throws MojoExecutionException If the checksum could not be installed.
*/
private void installChecksum( File installedFile, String ext, String checksum )
throws MojoExecutionException
{
File checksumFile = new File( installedFile.getAbsolutePath() + ext );
getLog().debug( "Installing checksum to " + checksumFile );
try
{
//noinspection ResultOfMethodCallIgnored
checksumFile.getParentFile().mkdirs();
FileUtils.fileWrite( checksumFile.getAbsolutePath(), "UTF-8", checksum );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Failed to install checksum to " + checksumFile, e );
}
}
代码示例来源:origin: org.talend.sdk.component/talend-component-maven-plugin
FileUtils.fileWrite(pomXml, pomEncoding, content);
} catch (final IOException e) {
throw new IllegalStateException(e);
代码示例来源:origin: org.apache.maven.shared/maven-verifier
/**
* Filters a text file by replacing some user-defined tokens.
*
* @param srcPath The path to the input file, relative to the base directory, must not be
* <code>null</code>.
* @param dstPath The path to the output file, relative to the base directory and possibly equal to the
* input file, must not be <code>null</code>.
* @param fileEncoding The file encoding to use, may be <code>null</code> or empty to use the platform's default
* encoding.
* @param filterProperties The mapping from tokens to replacement values, must not be <code>null</code>.
* @return The path to the filtered output file, never <code>null</code>.
* @throws IOException If the file could not be filtered.
* @since 1.2
*/
public File filterFile( String srcPath, String dstPath, String fileEncoding, Map<String, String> filterProperties )
throws IOException
{
File srcFile = new File( getBasedir(), srcPath );
String data = FileUtils.fileRead( srcFile, fileEncoding );
for ( String token : filterProperties.keySet() )
{
String value = String.valueOf( filterProperties.get( token ) );
data = StringUtils.replace( data, token, value );
}
File dstFile = new File( getBasedir(), dstPath );
//noinspection ResultOfMethodCallIgnored
dstFile.getParentFile().mkdirs();
FileUtils.fileWrite( dstFile.getPath(), fileEncoding, data );
return dstFile;
}
代码示例来源:origin: ch.sbb.releasetrain/utils-impl
FileUtils.fileWrite(gitDir.getAbsoluteFile() + "/" + pathAndFile, content);
} catch (IOException e) {
log.error(e.getMessage(), e);
内容来源于网络,如有侵权,请联系作者删除!