Here you can find the source of readFile(String file_name)
public static ArrayList<String> readFile(String file_name)
//package com.java2s; //License from project: Open Source License import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; public class Main { public static ArrayList<String> readFile(String file_name) { /* kamus */ ArrayList<String> list = null; Scanner scanner;/*from w w w .ja v a 2 s .c o m*/ /* algoritma */ try { // inisialisasi varibel list = new ArrayList<String>(); scanner = new Scanner(new FileInputStream(file_name)); // proses baca tiap baris while (scanner.hasNext()) { list.add(scanner.nextLine()); } // close stream scanner.close(); } catch (FileNotFoundException ex) { // JOptionPane.showMessageDialog(null, "Utils->readFile() ERROR! " + file_name, "Error", JOptionPane.ERROR_MESSAGE); //Logger.getLogger(FileImportUtils.class.getName()).log(Level.SEVERE, null, ex); return null; } return list; } }