Java Path File Read nio readLineS(String filePath, int line)

Here you can find the source of readLineS(String filePath, int line)

Description

Read the context of a specified line in a text file.

License

LGPL

Declaration

public static String readLineS(String filePath, int line) throws IOException 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.io.File;

import java.io.IOException;

import java.nio.file.Files;

import java.util.List;

public class Main {
    /**/*w  w  w. j a  va 2  s .  co  m*/
     * Read the context of a specified line in a text file.
     */
    public static String readLineS(String filePath, int line) throws IOException {
        File f = new File(filePath);
        List<String> lines = Files.readAllLines(f.toPath());
        return lines.get(line - 1);
    }
}

Related

  1. readJsonObject(Path path, TypeReference typeReference)
  2. readKeyFile(String path)
  3. readLine(BufferedReader br, Path path)
  4. readLineByLine(String filePath)
  5. readLines(Path path, boolean ignoreComments)
  6. readLinesFromFile(Path path)
  7. readLinesFromFileLazy(String path)
  8. readLinesOfFile(String path)
  9. readLineSP(String filePath, int line, int pos)