本文整理了Java中org.apache.archiva.common.utils.FileUtils
类的一些代码示例,展示了FileUtils
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils
类的具体详情如下:
包路径:org.apache.archiva.common.utils.FileUtils
类名称:FileUtils
[英]Utility class for file manipulation
[中]用于文件操作的实用程序类
代码示例来源:origin: apache/archiva
private void deleteDirectoryQuiet( Path f )
{
try
{
org.apache.archiva.common.utils.FileUtils.deleteDirectory( f );
}
catch ( IOException e )
{
log.warn( "skip error delete {} : {}", f, e.getMessage() );
}
}
代码示例来源:origin: apache/archiva
@Override
public void deleteVersion( VersionedReference reference )
{
String path = toMetadataPath( reference );
Path projectPath = Paths.get( getRepoRoot(), path );
Path projectDir = projectPath.getParent();
if ( Files.exists(projectDir) && Files.isDirectory(projectDir) )
{
org.apache.archiva.common.utils.FileUtils.deleteQuietly( projectDir );
}
}
代码示例来源:origin: apache/archiva
/**
* TODO: Remove in favor of using FileUtils directly.
*/
protected void writeStringToFile( Path file, String content )
throws IOException
{
org.apache.archiva.common.utils.FileUtils.writeStringToFile( file, Charset.defaultCharset(), content );
}
代码示例来源:origin: apache/archiva
public ChecksumFileContent parseChecksumFile( Path checksumFile, ChecksumAlgorithm expectedHash, Charset encoding )
String rawChecksumString = FileUtils.readFileToString( checksumFile, encoding );
String trimmedChecksum = rawChecksumString.replace( '\n', ' ' ).trim( );
代码示例来源:origin: apache/archiva
contents = org.apache.archiva.common.utils.FileUtils.readFileToString( file, Charset.defaultCharset() );
if ( !force && Files.exists( targetFile ) )
String targetContents = org.apache.archiva.common.utils.FileUtils.readFileToString( targetFile, Charset.defaultCharset( ) );
matching = targetContents.equals( contents );
代码示例来源:origin: apache/archiva
protected void revertMkDirs()
throws IOException
{
if ( createdDirs != null )
{
Collections.reverse( createdDirs );
while ( !createdDirs.isEmpty() )
{
Path dir = createdDirs.remove( 0 );
if ( Files.isDirectory(dir))
{
try(Stream<Path> str = Files.list(dir)) {
if (str.count()==0) {
org.apache.archiva.common.utils.FileUtils.deleteDirectory(dir);
}
}
}
else
{
//cannot rollback created directory if it still contains files
break;
}
}
}
}
代码示例来源:origin: apache/archiva
private void createChecksumFile( String path, Digester digester )
throws DigesterException, IOException
{
Path checksumFile = Paths.get( path + digester.getFilenameExtension() );
if ( !Files.exists(checksumFile) )
{
org.apache.archiva.common.utils.FileUtils.deleteQuietly( checksumFile );
checksum.createChecksum( Paths.get( path ).toFile(), digester );
}
else if ( !Files.isRegularFile( checksumFile) )
{
log.error( "Checksum file is not a file." );
}
}
代码示例来源:origin: apache/archiva
String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
代码示例来源:origin: apache/archiva
private void writeChecksumFile( Path checksumFile, Charset encoding, String checksumHex )
{
FileUtils.writeStringToFile( checksumFile, FILE_ENCODING, checksumHex + " " + referenceFile.getFileName( ).toString( ) );
}
代码示例来源:origin: apache/archiva
@Override
public void removeProject( String repositoryId, String namespace, String projectId )
throws MetadataRepositoryException
{
try
{
Path directory = getDirectory( repositoryId ).resolve( namespace + "/" + projectId );
org.apache.archiva.common.utils.FileUtils.deleteDirectory( directory );
}
catch ( IOException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
}
代码示例来源:origin: apache/archiva
@Override
public void deleteArtifact( ArtifactReference artifactReference )
{
String path = toPath( artifactReference );
Path filePath = Paths.get( getRepoRoot(), path );
if ( Files.exists(filePath) )
{
org.apache.archiva.common.utils.FileUtils.deleteQuietly( filePath );
}
Path filePathmd5 = Paths.get( getRepoRoot(), path + ".md5" );
if ( Files.exists(filePathmd5) )
{
org.apache.archiva.common.utils.FileUtils.deleteQuietly( filePathmd5 );
}
Path filePathsha1 = Paths.get( getRepoRoot(), path + ".sha1" );
if ( Files.exists(filePathsha1) )
{
org.apache.archiva.common.utils.FileUtils.deleteQuietly( filePathsha1 );
}
}
代码示例来源:origin: apache/archiva
String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
代码示例来源:origin: apache/archiva
@Override
public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataRepositoryException
{
try
{
Path directory = getDirectory( repoId ).resolve( namespace + "/" + projectId + "/" + projectVersion );
org.apache.archiva.common.utils.FileUtils.deleteDirectory( directory );
}
catch ( IOException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
}
代码示例来源:origin: apache/archiva
org.apache.archiva.common.utils.FileUtils.deleteQuietly(fileToMove);
代码示例来源:origin: apache/archiva
String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
代码示例来源:origin: apache/archiva
@Override
public void removeMetadataFacet( String repoId, String facetId, String name )
throws MetadataRepositoryException
{
try
{
Path dir = getMetadataDirectory( repoId, facetId ).resolve( name );
org.apache.archiva.common.utils.FileUtils.deleteDirectory( dir );
}
catch ( IOException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
}
代码示例来源:origin: apache/archiva
private Path writeMergedMetadataToFile( ArchivaRepositoryMetadata mergedMetadata, String outputFilename )
throws RepositoryMetadataException, DigesterException, IOException
{
Path outputFile = Paths.get( outputFilename );
if ( Files.exists(outputFile) )
{
org.apache.archiva.common.utils.FileUtils.deleteQuietly( outputFile );
}
Files.createDirectories(outputFile.getParent());
RepositoryMetadataWriter.write( mergedMetadata, outputFile );
createChecksumFile( outputFilename, digestSha1 );
createChecksumFile( outputFilename, digestMd5 );
return outputFile;
}
代码示例来源:origin: apache/archiva
String metadataXml = org.apache.archiva.common.utils.FileUtils.readFileToString( artifactMetadataFile, Charset.defaultCharset() );
代码示例来源:origin: apache/archiva
@Override
public void removeMetadataFacets( String repositoryId, String facetId )
throws MetadataRepositoryException
{
try
{
Path dir = getMetadataDirectory( repositoryId, facetId );
org.apache.archiva.common.utils.FileUtils.deleteDirectory( dir );
}
catch ( IOException e )
{
throw new MetadataRepositoryException( e.getMessage(), e );
}
}
代码示例来源:origin: apache/archiva
public static void write( ArchivaRepositoryMetadata metadata, Path outputFile )
throws RepositoryMetadataException
{
boolean thrown = false;
try (FileWriter writer = new FileWriter( outputFile.toFile() ))
{
write( metadata, writer );
writer.flush();
}
catch ( IOException e )
{
thrown = true;
throw new RepositoryMetadataException(
"Unable to write metadata file: " + outputFile.toAbsolutePath() + " - " + e.getMessage(), e );
}
finally
{
if ( thrown )
{
FileUtils.deleteQuietly( outputFile );
}
}
}
内容来源于网络,如有侵权,请联系作者删除!