Java Files get directory stream to list folder content

Description

Java Files get directory stream to list folder content

import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
  public static void main(String[] args) throws IOException {

    Path path = Paths.get("C:/");
    DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path);

     for (Path p : directoryStream) {
       System.out.println(p);//  www .j  a v  a 2  s  .  c o m
     }
  }
}



PreviousNext

Related