JAVA file read Write MD5 value unchanged method

Source: Internet
Author: User

If we want to read a file into the StringBuffer and write the new file, the new file MD5 value needs to remain the same (the new file is guaranteed to be identical to the source file),

We need to append the line break when manipulating StringBuffer:

1StringBuffer SB =NewStringBuffer ();2Reader rd =NULL;3BufferedReader br =NULL;4 5RD =NewFileReader ("e:/" is a ladies ' boy. html ");6BR =NewBufferedReader (RD);7String data =NULL;8          while(data = Br.readline ())! =NULL) {9 sb.append (data);TenSb.append ("\ r \ n");//stringbuffer Add a newline character when attaching content One  A             //The following are the Java newline characters under each operating system -             /// R Mac -             /// N unix/linux the             ///r/n Windows -  -}

This way, you can guarantee that MD5 will not change when you write to a new file using FileWrite.

JAVA file read Write MD5 value unchanged method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.