public static void copyFile(File source,File target) throws AdeUsageException {
  final String closeFail=" failed to close.";
  FileInputStream fisSource=null;
  FileOutputStream fosTarget=null;
  FileChannel inputChannel=null;
  FileChannel outputChannel=null;
  try {
    fisSource=new FileInputStream(source);
    fosTarget=new FileOutputStream(target);
    inputChannel=fisSource.getChannel();
    outputChannel=fosTarget.getChannel();
    outputChannel.transferFrom(inputChannel,0,inputChannel.size());
    inputChannel.close();
    inputChannel=null;
    outputChannel.close();
    outputChannel=null;
    fisSource.close();
    fisSource=null;
    fosTarget.close();
    fosTarget=null;
  }
 catch (  IOException e) {
    throw new AdeUsageException("Copy file utility error",e);
  }
 finally {
    if (inputChannel != null) {
      try {
        inputChannel.close();
      }
 catch (      IOException e1) {
        logger.warn(inputChannel.toString() + closeFail,e1);
      }
    }
    if (outputChannel != null) {
      try {
        outputChannel.close();
      }
 catch (      IOException e1) {
        logger.warn(outputChannel.toString() + closeFail,e1);
      }
    }
    if (fisSource != null) {
      try {
        fisSource.close();
      }
 catch (      IOException e1) {
        logger.warn(fisSource.toString() + closeFail,e1);
      }
    }
    if (fosTarget != null) {
      try {
        fosTarget.close();
      }
 catch (      IOException e1) {
        logger.warn(fosTarget.toString() + closeFail,e1);
      }
    }
  }
}

public static void copyFile ( File source , File target ) throws AdeUsageException { final String closeFail = " failed to close." ; FileInputStream fisSource = null ; FileOutputStream fosTarget = null ; FileChannel inputChannel = null ; FileChannel outputChannel = null ; try { fisSource = new FileInputStream ( source ) ; fosTarget = new FileOutputStream ( target ) ; inputChannel = fisSource . getChannel ( ) ; outputChannel = fosTarget . getChannel ( ) ; outputChannel . transferFrom ( inputChannel , 0 , inputChannel . size ( ) ) ; inputChannel . close ( ) ; inputChannel = null ; outputChannel . close ( ) ; outputChannel = null ; fisSource . close ( ) ; fisSource = null ; fosTarget . close ( ) ; fosTarget = null ; } catch ( IOException e ) { throw new AdeUsageException ( "Copy file utility error" , e ) ; } finally { if ( inputChannel != null ) { try { inputChannel . close ( ) ; } catch ( IOException e1 ) { logger . warn ( inputChannel . toString ( ) + closeFail , e1 ) ; } } if ( outputChannel != null ) { try { outputChannel . close ( ) ; } catch ( IOException e1 ) { logger . warn ( outputChannel . toString ( ) + closeFail , e1 ) ; } } if ( fisSource != null ) { try { fisSource . close ( ) ; } catch ( IOException e1 ) { logger . warn ( fisSource . toString ( ) + closeFail , e1 ) ; } } if ( fosTarget != null ) { try { fosTarget . close ( ) ; } catch ( IOException e1 ) { logger . warn ( fosTarget . toString ( ) + closeFail , e1 ) ; } } } }
copy a file on the filesystem .
