Java Text File Read Line readLines(String text)

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

Description

read Lines

License

LGPL

Declaration

public static String[] readLines(String text) 

Method Source Code

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

import java.io.BufferedReader;

import java.io.IOException;

import java.io.StringReader;

import java.util.Collection;

import java.util.LinkedList;

public class Main {
    public static String[] readLines(String text) {
        StringReader reader = new StringReader(text);
        BufferedReader bufReader = new BufferedReader(reader);
        Collection<String> tmpOut = new LinkedList<String>();
        String line;/*from w  w  w. java2 s. com*/
        try {
            line = bufReader.readLine();
            while (line != null) {
                tmpOut.add(line);
                line = bufReader.readLine();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        String[] out = new String[tmpOut.size()];
        tmpOut.toArray(out);
        return out;
    }
}

Related

  1. readLines(String filePath)
  2. readLines(String fullFileName)
  3. readLines(String lines)
  4. readLines(String string)
  5. readLines(String targetPath)
  6. readLines(String text)
  7. readLines2Lowcase(String inputFile, ArrayList lines)
  8. readLinesAsList(String filename)
  9. readLinesFileSimple(final File inFile, final int prefixMode, final String prefix)