title: Read file using Java nio files walk()
body: <p>I am using stream API to read files I am calling <code>readFile()</code> method while iterating loop in first loop I am getting path value how to remove that path value because of that I am facing array index out of bound exception.
  file naming converstion is "FileName_17072018".</p>
  
  <pre><code>public class RemoveCVVFilesjob {
  
      public static void main(String[] args) throws IOException {
          List&lt;String&gt; fileList;
          fileList = readFile();
  
          for (String str : fileList) {
              String[] strArr = str.split("_");
              System.out.println(strArr[1]);
          }
      }
  
      private static List&lt;String&gt; readFile() throws IOException {
  
          try (Stream&lt;Path&gt; paths = Files.walk(Paths.get("D:\\Projects\\Wallet\\CVVFiles"))) {
  
              List&lt;String&gt; list = paths.map(path -&gt; Files.isDirectory(path) ? 
                  path.getFileName().toString() + '/' : 
                  path.getFileName().toString()).collect(Collectors.toList()
              );
              return list;
          }
      }
  </code></pre>