Here you can find the source of readFileAsArray(String path)
public static String[] readFileAsArray(String path) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String[] readFileAsArray(String path) throws IOException { String[] result = new String[] {}; InputStream in = new FileInputStream(path); BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); String line = ""; int i = 0; while ((line = reader.readLine()) != null) { line = line.trim();//from www. j av a2 s . co m if (line == null || "".equals(line)) { continue; } result[i] = line; } reader.close(); return result; } }