title: java 8 stream multiple filters
body: <p>I am new to Java 8 and trying a requirement on Streams. I have a csv file with thousands of recods my csv format is</p>
  
  <pre>
  DepId,GrpId,EmpId,DepLocation,NoofEmployees,EmpType
  ===
  D100,CB,244340,USA,1000,Contract
  D101,CB,543126,USA,1900,Permanent
  D101,CB,356147,USA,1800,Contract
  D100,DB,244896,HK,500,SemiContract
  D100,DB,543378,HK,100,Permanent
  </pre>
  
  <p>My requirement is to filter the records with two conditions
  a) EmpId starts with "244" or EmpId starts with "543"
  b) EmpType is "Contract" and "Permanent"</p>
  
  <p>I tried below</p>
  
  <pre><code> try (Stream&lt;String&gt; stream = Files.lines(Paths.get(fileAbsolutePath))) {
      list = stream                
          .filter(line -&gt; line.contains("244") || line.contains("543"))
          .collect(Collectors.toList());
       }
  </code></pre>
  
  <p>It is filtering the employees based on 244 and 543 but my concern is since i am using contains it might fetch other data also i.e. it will fetch the data not only from EmpId column but also from other columns(other columns might also have data starting with these numbers)</p>
  
  <p>similarly to incorporate EmpType as i am reading line by line there is no way for me to enforce that EmpType should be in "Permanent" and "Contract" </p>
  
  <p>Am i missing any advanced options??</p>