Java Path File Read nio loadStrings(Path thePath)

Here you can find the source of loadStrings(Path thePath)

Description

load Strings

License

Open Source License

Declaration

static public List<String> loadStrings(Path thePath) 

Method Source Code

//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);
        }
    }
}

Related

  1. loadFile(String path)
  2. loadFromFile(Path path)
  3. loadJSON(Path path)
  4. loadProperties(Path filePath)
  5. loadProperties(Supplier classLoader, String classpathResource)
  6. loadStringsFromFile(String pathToFile)
  7. loadTestPackets(final Path path)
  8. loadTitles(Path rootDir, Set container)
  9. newBufferedReader(Path path)