本文整理了Java中org.apache.maven.shared.utils.io.FileUtils.fileRead()
方法的一些代码示例,展示了FileUtils.fileRead()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.fileRead()
方法的具体详情如下:
包路径:org.apache.maven.shared.utils.io.FileUtils
类名称:FileUtils
方法名:fileRead
[英]Note: the file content is read with platform encoding
[中]注意:使用平台编码读取文件内容
代码示例来源:origin: fabric8io/docker-maven-plugin
public static Date loadTimestamp(File tsFile) throws IOException {
try {
if (tsFile.exists()) {
String ts = FileUtils.fileRead(tsFile);
return new Date(Long.parseLong(ts));
} else {
return null;
}
} catch (IOException e) {
throw new IOException("Cannot read timestamp " + tsFile,e);
}
}
代码示例来源:origin: org.apache.maven.shared/maven-verifier
private static String getLogContents( File logFile )
{
try
{
return FileUtils.fileRead( logFile );
}
catch ( IOException e )
{
// ignore
return "(Error reading log contents: " + e.getMessage() + ")";
}
}
代码示例来源:origin: org.apache.maven.shared/maven-shared-utils
/**
* Note: the file content is read with platform encoding
*
* @param file the file path
* @return the file content using the platform encoding.
* @throws IOException if any
*/
@Nonnull public static String fileRead( @Nonnull File file )
throws IOException
{
return fileRead( file, null );
}
代码示例来源:origin: org.apache.maven.shared/maven-shared-utils
/**
* Note: the file content is read with platform encoding.
*
* @param file the file path
* @return the file content using the platform encoding.
* @throws IOException if any
*/
@Nonnull public static String fileRead( @Nonnull String file )
throws IOException
{
return fileRead( file, null );
}
代码示例来源:origin: org.apache.maven.shared/maven-shared-utils
/**
* @param file the file path
* @param encoding the wanted encoding
* @return the file content using the specified encoding.
* @throws IOException if any
*/
@Nonnull private static String fileRead( @Nonnull String file, @Nullable String encoding )
throws IOException
{
return fileRead( new File( file ), encoding );
}
代码示例来源:origin: org.apache.maven.shared/maven-verifier
public void assertArtifactContents( String org, String artifact, String version, String type, String contents )
throws IOException
{
String fileName = getArtifactPath( org, artifact, version, type );
Assert.assertEquals( contents, FileUtils.fileRead( fileName ) );
}
代码示例来源:origin: org.apache.maven.shared/maven-verifier
/**
* Check that given file's content matches an regular expression. Note this method also checks that the file exists
* and is readable.
*
* @param file the file to check.
* @param regex a regular expression.
* @see Pattern
*/
public void assertFileMatches( String file, String regex )
{
assertFilePresent( file );
try
{
String content = FileUtils.fileRead( file );
if ( !Pattern.matches( regex, content ) )
{
Assert.fail( "Content of " + file + " does not match " + regex );
}
}
catch ( IOException e )
{
Assert.fail( e.getMessage() );
}
}
代码示例来源:origin: org.talend.sdk.component/talend-component-maven-plugin
String content = FileUtils.fileRead(pomXml);
if (content.contains("<artifactId>component-api</artifactId>")) {
getLog().debug("component-api already in " + pomXml);
代码示例来源: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: org.apache.maven.shared/maven-script-interpreter
try
script = FileUtils.fileRead( scriptFile, encoding );
内容来源于网络,如有侵权,请联系作者删除!