Here you can find the source of readLineSP(String filePath, int line, int pos)
public static String readLineSP(String filePath, int line, int pos) throws IOException
//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 { /**/*from ww w . j a va2s.c o m*/ * Read the context after a specified position of a line in a text file. */ public static String readLineSP(String filePath, int line, int pos) throws IOException { pos -= 1; String l = readLineS(filePath, line); if (l.length() < pos) pos = l.length(); l = l.substring(pos, l.length()); return l; } /** * 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); } }