Buffer the array size is 2, then each loop only to temp array into two characters, each call to the write method can only write two bytes, why not take cover before writing? The ouput constructor will not cover??
CodePudding user response:
Problem has been solved, see the write () method of source and found this method is additional written not cover written, step by step in the debug runtime found running through the output=new FileOutputStream (dest); After the content of the target file will be empty () when the file exists, and then call the write () method will buffer in the array data appended to the fileCodePudding user response:
That cover the destination file content not because call write () method, but because the output=new FileOutputStream (dest); This statement clear purpose file content