Files Comparison using Files.mismatch() in Java 12

Java 12 brought some useful additions and comparing two files using a newly added method ‘Mismatch()’ is one of them. In this post, we will learn “How to use Files.mismatch() method introduced in Java 12?”. 

Here, we are going to learn the following things:

  1. What is Files.mismatch() method?
  2. How to use it?

Compare files with Files.mismatch() in Java 12...!!! Click To Tweet

 

Let’s Begin,

1. What is Files.mismatch() method?

This method returns the position of the first mismatch or -1L if there is no mismatch. 

Files_Mismatch_Java12_Signature

2. How to use it?

Let’s take an example where we have a few temp files. First, we are comparing the files which are identical, and later comparing the unidentical ones using ‘mismatch()’ method. 

 

Output:

 

Compare files with Files.mismatch() in Java 12...!!! Click To Tweet

Do you like this Post? – then check my other helpful posts:

Other Useful References:

 

Related Posts:

[wcp-carousel id=”5342″]

Promotional Content:

Loading RSS Feed

Leave a Reply

Your email address will not be published.Required fields are marked *

Facebook Twitter Instagram YouTube