Java UTF8 File Read readAllLines(File inputFile)

Here you can find the source of readAllLines(File inputFile)

Description

read All Lines

License

Open Source License

Declaration

public static List<String> readAllLines(File inputFile) throws IOException 

Method Source Code


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

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<String> readAllLines(File inputFile) throws IOException {
        List<String> ret = new ArrayList<String>();
        String line;//from ww w . jav  a2s  .  c o m
        BufferedReader br = null;
        try {
            InputStream fis = new FileInputStream(inputFile);
            InputStreamReader isr = new InputStreamReader(fis, Charset.forName("UTF-8"));
            br = new BufferedReader(isr);
            while ((line = br.readLine()) != null) {
                ret.add(line);
            }
        } finally {
            if (br != null)
                br.close();
        }
        return ret;
    }
}

Related

  1. getUTF8Reader(File f)
  2. loadUTF8(File file)
  3. makeUTF8Reader(InputStream inputStream)
  4. newUtf8Reader(final InputStream in)
  5. openFileReaderUTF8(File file)
  6. readAsUTF8(String text)
  7. readLines(File inputFile)
  8. readRawUTF8Bytes(final byte[] bytes)
  9. readResourceUtf8(Class contextClass, String filename)