Java Text File Read Line readLines(String body)

Here you can find the source of readLines(String body)

Description

read Lines

License

Open Source License

Declaration

public static List<String> readLines(String body) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<String> readLines(String body) {
        final BufferedReader reader = new BufferedReader(new StringReader(body));
        final List<String> lines = new ArrayList<String>();
        try {/*from   ww  w .j  a v  a  2  s .  c o  m*/
            for (String line = reader.readLine(); line != null; line = reader.readLine()) {
                line = line.trim();
                if (line.length() > 1) {
                    lines.add(line);
                }
            }
        } catch (IOException ignored) {
        }
        return lines;
    }
}

Related

  1. readLines(File inputFile)
  2. readLines(File inputFile, String encoding)
  3. readLines(final File file)
  4. readlines(final File file)
  5. readLines(int problemNumber)
  6. readLines(String file)
  7. readLines(String file)
  8. readLines(String file, ArrayList lines)
  9. readLines(String filename)