Here you can find the source of readAll(File file)
Parameter | Description |
---|---|
file | File to read |
Parameter | Description |
---|---|
IOException | an exception |
public static List<String> readAll(File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.util.ArrayList; import java.util.List; public class Main { /**/*from w w w . java 2s. c o m*/ * Simple method to read all the contents of a file * @param file File to read * @return The contents * @throws IOException */ public static List<String> readAll(File file) throws IOException { BufferedReader reader = new BufferedReader(new FileReader(file)); List<String> lines = new ArrayList<String>(); while (reader.ready()) lines.add(reader.readLine()); reader.close(); return lines; } }