I have asked this question in order to help with this topic:
I am trying to create a copying process, but not complete, that is, only update the contents of one file with the changes made in another.
- I explain:
I have created two txt files, one with the name A and another with the name B, both files have the same data, until my program alters the data in file A, making changes in the writing (Not deleting the content and writing another but only adding more content), and once these changes are made I want to update or add only the changes that were made not all the content again, just copy what you do not have or lack.
My current code:
My code was very useful when it was time to copy the input data to a file, doing the conversion of InputStream to File, unfortunately it does not perform this operation that I need
My code:
public boolean creaArchivo2(String ruta, InputStream is)
throws IOException {
final int CHUNK_SIZE = 1024 * 4;
OutputStream os = new BufferedOutputStream(new FileOutputStream(new File(ruta)));
byte[] chunk = new byte[CHUNK_SIZE];
int bytesLeidos = 0;
while ( (bytesLeidos = is.read(chunk)) > 0) {
os.write(chunk, 0, bytesLeidos);
}
os.close();
boolean verdadero=true;
return verdadero;
}
If you know how to achieve it, please let me know Thank you.