Here you can find the source of loadStrings(Path thePath)
static public List<String> loadStrings(Path thePath)
//package com.java2s; /*/*from w w w.ja va 2s.c om*/ * Copyright (c) 2013 christianr. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.html * * Contributors: * christianr - initial API and implementation */ import java.io.BufferedReader; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; public class Main { static public List<String> loadStrings(Path thePath) { try { BufferedReader reader = Files.newBufferedReader(thePath); List<String> myResult = new ArrayList<>(); String line = null; while ((line = reader.readLine()) != null) { myResult.add(line); } reader.close(); return myResult; } catch (IOException e) { throw new RuntimeException("Error inside loadStrings()", e); } } }