Path booksPath = Paths.get("books.txt");
if (Files.exists(booksPath))
{
File booksFile = booksPath.toFile();
try (BufferedReader in =
new BufferedReader( // implements buffered reading from a character stream
new FileReader(booksFile))) // implements reading character files
{
String line = in.readLine();
while(line != null)
{
System.out.println(line);
line = in.readLine();
}
}
catch (IOException e)
{
System.out.println(e);
}
}
else
{
System.out.println(
booksPath.toAbsolutePath() +
" doesn't exist");
}