public static void copyFromFileToFile(File source, File dest) throws IOException{
		try {
			FileInputStream in = new FileInputStream(source);
			FileOutputStream out = new FileOutputStream(dest);
			try {
				FileChannel canalFuente = in.getChannel();
				FileChannel canalDestino = out.getChannel();
				canalFuente.transferTo(0, canalFuente.size(), canalDestino);
			} catch (IOException e) {
				throw new IOException("copiando ficheros orig:'" + source.getAbsolutePath()
						+ "' destino:'" + dest.getAbsolutePath() + "'", e);
			} finally {
				IOUtils.closeQuietly(in);
				IOUtils.closeQuietly(out);
//				try { 
//					in.close();
//				} catch (IOException e) {
//				}
//				try {
//					out.close();
//				} catch (IOException e) {
//				}
			}
		} catch (FileNotFoundException e) {
			throw new IOException("copiando ficheros orig:'" + source.getAbsolutePath()
					+ "' destino:'" + dest.getAbsolutePath() + "'", e);
		}
	}
public static void copyFromFileToFile ( File source , File dest ) throws IOException { try { FileInputStream in = new FileInputStream ( source ) ; FileOutputStream out = new FileOutputStream ( dest ) ; try { FileChannel canalFuente = in . getChannel ( ) ; FileChannel canalDestino = out . getChannel ( ) ; canalFuente . transferTo ( 0 , canalFuente . size ( ) , canalDestino ) ; } catch ( IOException e ) { throw new IOException ( "copiando ficheros orig:'" + source . getAbsolutePath ( ) + "' destino:'" + dest . getAbsolutePath ( ) + "'" , e ) ; } finally { IOUtils . closeQuietly ( in ) ; IOUtils . closeQuietly ( out ) ; } } catch ( FileNotFoundException e ) { throw new IOException ( "copiando ficheros orig:'" + source . getAbsolutePath ( ) + "' destino:'" + dest . getAbsolutePath ( ) + "'" , e ) ; } }
Copia el contenido de un fichero a otro en caso de error lanza una excepcion.
@param source
@param dest
@throws IOException