title: How to mask the content of a text file in Java
body: <p>I am looking to mask the content of a text file.</p>
  
  <p>Ex: The text file contains data like</p>
  
  <pre><code>Peter|peter@gmail.com|312-445-9988|....|  
  John|john@gmail.com|123-457-6789|....|
  </code></pre>
  
  <p>Expected Output:</p>
  
  <pre><code>Peter|XXXXX@gmail.com|XXX-XXX-XXXX|....|  
  John|XXXX@gmail.com|XXX-XXX-XXXX|....|
  </code></pre>
  
  <p>I have to mask the content like phone number and mail ID till peter not @gmail.com</p>
  
  <p>Here is my code that I tried I have tried till reading the data from the text file after that I am not getting any ideas...</p>
  
  <pre><code>public class DataMasking {
  public static void main(String args[]) throws IOException{
  
      BufferedReader in = new BufferedReader(new FileReader("Filepath"));
      String str;
  
      List&lt;String&gt; parts = new ArrayList&lt;String&gt;();
      while ((str = in.readLine()) != null) {
  
          parts.add(str);
          }
      int size = parts.size();
      //we are reducing the size by one because we are not counting the first line(Only contains file name and time stamp).
      size = size-1;
      System.out.println("The Number of lines in the text file  "+size);
  </code></pre>
  
  <p>Any help is appreciated. </p>