How to read a file into an arraylist in java

How to read a file into an arraylist in java

test.txt

refer to‮ttual:‬uri.com
lautturi
hello world
java
python
perl
js
/**
 * @author lautturi.com 
 * Java example: read a text file to arraylist in java
 */

import java.io.File;
import java.io.IOException;
import java.util.*;

public class Lautturi {

	public static void main(String[] args) throws IOException {

		Scanner s = new Scanner(new File("test.txt"));
		ArrayList<String> list = new ArrayList<String>();
		while (s.hasNext()){
		    list.add(s.next());
		}
		s.close();
		
		System.out.println(list);
	}
}

output:

[lautturi, hello, world, java, python, perl, js]
Created Time:2017-09-30 23:14:04  Author:lautturi