I am downloading some file Audio/Video/PDF from amazon S3 server. What I am doing is at the start of download encrypt the only first 256kb for each file.
Recently I add resume functionality. What I want to do is to wait for complete downloading of file. One completed then I will encrypt the frist 256kb of file.
I want to encrypt first 256kb of file without creating a new file for that. As if I create a new then after 256kb I have to copy the other bytes to new file. This will take time as file size can be 200MB to 500MB.
What is the best solution for that?
I am using JDK1.6 Downloading is via input/output stream.
import java.io.InputStream;
import java.io.FileOutputStream;
You might want to use RandomAccessFile. Read your 250K, encrypt on memory, overwrite in the same file.