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

String[]readLines(String text)
read Lines
return text.split("\\r?\\n");
voidreadLines2Lowcase(String inputFile, ArrayList lines)
read Lines Lowcase
BufferedReader reader = null;
try {
    reader = new BufferedReader(new FileReader(new File(inputFile)));
    String line = null;
    while ((line = reader.readLine()) != null) {
        lines.add(line.toLowerCase());
} catch (FileNotFoundException e) {
...
ArrayListreadLinesAsList(String filename)
read Lines As List
FileReader fileReader = new FileReader(filename);
BufferedReader bufferedReader = new BufferedReader(fileReader);
ArrayList<String> lines = new ArrayList<String>();
String line = null;
while ((line = bufferedReader.readLine()) != null) {
    lines.add(line);
bufferedReader.close();
...
StringreadLinesFileSimple(final File inFile, final int prefixMode, final String prefix)
Implementation Routine readLinesFileSimple.
try {
    return readLinesFile(inFile, prefixMode, prefix);
} catch (IOException e) {
    e.printStackTrace();
return "";
intreadLinesFromCommand(String command[], List buffer)
read Lines From Command
if (command == null || buffer == null) {
    return -2;
Process cmdProc = null;
try {
    cmdProc = Runtime.getRuntime().exec(command);
} catch (IOException e) {
    System.out.printf("`%s` failed\n", Arrays.toString(command));
...
ListreadLinesNoComments(String fileName)
read Lines No Comments
return readLinesNoComments(fileName, null);
StringreadLinesRaw(final File inFile)
Count the number of lines in the buffer.
final StringBuffer resultBuffer = new StringBuffer(128);
final FileInputStream stream = new FileInputStream(inFile);
final BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
try {
    String data = "";
    int lineNumber = 1;
    do {
        data = reader.readLine();
...
String[]readLinesTrimmedNoComment(final String fileName, final String commentString)
read Lines Trimmed No Comment
File wtsFile = new File(fileName);
if (!wtsFile.isFile())
    throw new FileNotFoundException("Cannot find file for reading: " + fileName);
FileInputStream fin = null;
BufferedReader in = null;
try {
    fin = new FileInputStream(wtsFile);
    in = new BufferedReader(new InputStreamReader(fin));
...
ArrayListreadLinesWithPattern(File file, Pattern pattern)
read Lines With Pattern
ArrayList<String> strs = new ArrayList<>();
try {
    Scanner sc = new Scanner(file);
    while (sc.hasNextLine()) {
        Scanner lineSc = new Scanner(sc.nextLine());
        String str = lineSc.findInLine(pattern);
        if (str != null) {
            strs.add(str.trim());
...