Java Utililty Methods Text File Read Line

List of utility methods to do Text File Read Line

Description

The list of methods to do Text File Read Line are organized into topic(s).

Method

ArrayListreadLines(String filename)
read Lines
File f = new File(filename);
if (!f.exists()) {
    try {
        f.createNewFile();
    } catch (IOException e) {
        e.printStackTrace();
try {
    BufferedReader br = new BufferedReader(new FileReader(filename));
    String line;
    ArrayList<String> lines = new ArrayList<String>();
    while ((line = br.readLine()) != null) {
        lines.add(line);
    br.close();
    return lines;
} catch (IOException localIOException) {
    localIOException.printStackTrace();
return null;
ListreadLines(String fileName)
Reads the lines of the given file.
List<String> result = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName)));
String line = "";
do {
    line = reader.readLine();
    if (line != null) {
        result.add(line);
} while (line != null);
reader.close();
return result;
ListreadLines(String filePath)
read Lines
FileReader fr = new FileReader(filePath);
BufferedReader br = new BufferedReader(fr);
List<String> lines = new ArrayList<String>();
String line;
try {
    while ((line = br.readLine()) != null)
        lines.add(line);
} finally {
...
ListreadLines(String filePath)
read Lines
try {
    FileReader fr = new FileReader(filePath);
    BufferedReader br = new BufferedReader(fr);
    List<String> res = new ArrayList<>();
    String buf;
    while ((buf = br.readLine()) != null) {
        res.add(buf);
    br.close();
    fr.close();
    return res;
} catch (IOException e) {
    e.printStackTrace();
return null;
ListreadLines(String filePath)
read Lines
return readLines(filePath, "utf-8");
StringreadLines(String fullFileName)
read Lines
FileReader fr = null;
BufferedReader br = null;
try {
    File file = new File(fullFileName);
    fr = new FileReader(file);
    br = new BufferedReader(fr);
    String line = null;
    StringBuffer sb = new StringBuffer();
...
LinkedListreadLines(String lines)
Return a LinkedList of the lines in a string that aren't comments.
BufferedReader bufferedReader = null;
LinkedList<String> returnList = new LinkedList<String>();
String line;
bufferedReader = new BufferedReader(new StringReader(lines));
try {
    while ((line = bufferedReader.readLine()) != null) {
        line = line.trim();
        if (!(line.length() == 0 || line.startsWith("/*") || line.startsWith("//"))) {
...
ListreadLines(String string)
read Lines
File file = new File(string);
return readLines(file);
ListreadLines(String targetPath)
read Lines
BufferedReader reader = null;
try {
    reader = new BufferedReader(new FileReader(targetPath));
    List<String> rs = new ArrayList<String>();
    String line = reader.readLine();
    while (line != null) {
        rs.add(line);
        line = reader.readLine();
...
String[]readLines(String text)
read Lines
StringReader reader = new StringReader(text);
BufferedReader bufReader = new BufferedReader(reader);
Collection<String> tmpOut = new LinkedList<String>();
String line;
try {
    line = bufReader.readLine();
    while (line != null) {
        tmpOut.add(line);
...