Here you can find the source of readFile(File f)
Parameter | Description |
---|---|
f | Input file. |
f
.
public static String[] readFile(File f) throws IOException
//package com.java2s; /* Copyright (C) 2003 Univ. of Massachusetts Amherst, Computer Science Dept. This file is part of "MALLET" (MAchine Learning for LanguagE Toolkit). http://www.cs.umass.edu/~mccallum/mallet This software is provided under the terms of the Common Public License, version 1.0, as published by http://www.opensource.org. For further information, see the file `LICENSE' included with this distribution. */ import java.io.*; import java.util.ArrayList; public class Main { /**/* w ww . java 2 s.c o m*/ * Reads every line from a given text file. * @param f Input file. * @return String[] Array containing each line in <code>f</code>. */ public static String[] readFile(File f) throws IOException { BufferedReader in = new BufferedReader(new FileReader(f)); ArrayList list = new ArrayList(); String line; while ((line = in.readLine()) != null) list.add(line); return (String[]) list.toArray(new String[0]); } }