title: How to check if text stored in file contains new line character(Enter) using java?
body: <p>I'm trying to read data stored in text file and check if file's data contains new line character or not.
  For example: if file contains data:</p>
  
  <pre><code>This is first line.
  This is second line.
  </code></pre>
  
  <p>Then my program should say that first line contains new line character.</p>
  
  <p>I tried using </p>
  
  <pre><code>File file = new File(System.getProperty("user.dir") + File.separator + "test.txt");
  BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
  String line;
  while ((line = bufferedReader.readLine()) != null)
  {                       
      char[] arr = line.toCharArray();
      for(char test: arr)
          if(String.valueOf(test) == System.getProperty("line.separator"))
              System.out.println("Contains new line");
  }
  </code></pre>
  
  <p>and I also tried this code</p>
  
  <pre><code>while ((line = bufferedReader.readLine()) != null)
  {
      if (line.contains(System.getProperty("line.separator")))
          System.out.println("Contains new line");
  }
  </code></pre>
  
  <p>but to no avail.</p>
  
  <p>My file does contains new line character. In notepad++ if I search for \n or \r\n then it does shows new line character in file. But some how my code is not recognizing it.</p>