Android Text File Read readFile(String path)

Here you can find the source of readFile(String path)

Description

read File

Declaration

public static Set<String> readFile(String path) 

Method Source Code

//package com.java2s;
import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

public class Main {

    public static Set<String> readFile(String path) {
        Set<String> set = new HashSet<String>();
        try {/*from  w w w . ja  v  a  2s .c om*/
            BufferedReader br = new BufferedReader(new FileReader(path));
            String line = null;
            while ((line = br.readLine()) != null) {
                set.add(line.trim());
            }
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return set;
    }
}

Related

  1. readFile(File in)
  2. readFile(String fileName)
  3. readFile(String fileName)
  4. readFile(String filePath)
  5. readFile(String filename)
  6. readFileAsString(File file)
  7. readFileAsString(File file, String charset)
  8. readFileAsString(String filename)
  9. readFileLineByLine(File file)