Java Scanner Read readFile(String fileName)

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

Description

read File

License

Open Source License

Declaration

public static List<String> readFile(String fileName) throws FileNotFoundException 

Method Source Code

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

import java.io.File;
import java.io.FileNotFoundException;

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

public class Main {
    public static List<String> readFile(String fileName) throws FileNotFoundException {
        Scanner s = new Scanner(new File(fileName));
        List<String> list = new ArrayList<String>();
        while (s.hasNext()) {
            list.add(s.next());//from w w  w .  j av a 2s.c om
        }
        s.close();
        return list;

    }
}

Related

  1. readFile(File input)
  2. readFile(File path)
  3. readFile(final File f)
  4. readFile(String file_name)
  5. readFile(String filename)
  6. readFile(String fileName)
  7. readFile(String fileName)
  8. readFile(String filePath)
  9. readFile(String filePath)