Skip to content

Instantly share code, notes, and snippets.

@chaitanyamannem
Created May 7, 2020 14:14
Show Gist options
  • Save chaitanyamannem/b7316e491bbeb78e913b05035f7c98f1 to your computer and use it in GitHub Desktop.
Save chaitanyamannem/b7316e491bbeb78e913b05035f7c98f1 to your computer and use it in GitHub Desktop.
import java.io.IOException;
import java.nio.file.*;
import java.util.stream.*;
public class Main {
public static void main(String[] args) {
Stream<String> filenames = null;
try {
filenames = Files.lines(Paths.get("first.txt"));
}catch (IOException ioe){
ioe.printStackTrace();
}
if(filenames != null)
System.out.println("Printing content:\n" + filenames.collect(Collectors.toList()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment