fabiojose
11/26/2014 - 6:28 PM

Java.IO.Copy.File

Java.IO.Copy.File

public class CopyFile {

  public void copy(final File from, final File to) throws IOException {

    final FileInputStream _fromStream = new FileInputStream(from);
    final FileOutputStream _toStream  = new FileOutputStream(to);
    try{

      byte[] _buffer = new byte[2048];
      int _length      = 0;
      while(-1!= (_length = _fromStream.read(_buffer))){
        _toStream.write(_buffer, 0, _length);
      }
	
    }finally{
      _fromStream.close();
      _toStream.close();
    }
  }

}