org.sonatype.aether.impl.internal
Class DefaultFileProcessor
java.lang.Object
org.sonatype.aether.impl.internal.DefaultFileProcessor
- All Implemented Interfaces:
- FileProcessor
@Component(role=FileProcessor.class)
public class DefaultFileProcessor
- extends java.lang.Object
- implements FileProcessor
A utility class helping with file-based operations.
- Author:
- Benjamin Hanzelmann
Method Summary |
long |
copy(java.io.File src,
java.io.File target,
FileProcessor.ProgressListener listener)
Copy src- to target-file. |
boolean |
mkdirs(java.io.File directory)
Thread-safe variant of File.mkdirs() . |
void |
write(java.io.File file,
java.lang.String data)
Write the given data to a file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DefaultFileProcessor
public DefaultFileProcessor()
mkdirs
public boolean mkdirs(java.io.File directory)
- Thread-safe variant of
File.mkdirs()
. Adapted from Java 6. Creates the directory named by the given
abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails
it may have succeeded in creating some of the necessary parent directories.
- Specified by:
mkdirs
in interface FileProcessor
- Parameters:
directory
- The directory to create, may be null
.
- Returns:
true
if and only if the directory was created, along with all necessary parent directories;
false
otherwise
copy
public long copy(java.io.File src,
java.io.File target,
FileProcessor.ProgressListener listener)
throws java.io.IOException
- Copy src- to target-file. Creates the necessary directories for the target file. In case of an error, the created
directories will be left on the file system.
- Specified by:
copy
in interface FileProcessor
- Parameters:
src
- the file to copy from, must not be null
.target
- the file to copy to, must not be null
.listener
- the listener to notify about the copy progress, may be null
.
- Returns:
- the number of copied bytes.
- Throws:
java.io.IOException
- if an I/O error occurs.
write
public void write(java.io.File file,
java.lang.String data)
throws java.io.IOException
- Write the given data to a file. UTF-8 is assumed as encoding for the data.
- Specified by:
write
in interface FileProcessor
- Parameters:
file
- The file to write to, must not be null
. This file will be truncated.data
- The data to write, may be null
.
- Throws:
java.io.IOException
- if an I/O error occurs.
Copyright © 2010 Sonatype, Inc.. All Rights Reserved.