Here you can find the source of readFile(String fileName, String commentFlag)
Parameter | Description |
---|---|
fileName | a parameter |
commentFlag | The leading character indicating a line of comment. |
public static StringBuffer readFile(String fileName, String commentFlag)
//package com.java2s; /*// ww w .j av a2s . com JavaRAP: a freely-available JAVA anaphora resolution implementation of the classic Lappin and Leass (1994) paper: An Algorithm for Pronominal Anaphora Resolution. Computational Linguistics, 20(4), pp. 535-561. Copyright (C) 2005,2006 Long Qiu This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import java.io.*; public class Main { public static StringBuffer readFile(String fileName) { return readFile(fileName, null); } /** * @param fileName * @param commentFlag The leading character indicating a line of comment. * @return The content, preferably plain text, of the file "fileName", with the comments ignored. */ public static StringBuffer readFile(String fileName, String commentFlag) { StringBuffer sb = new StringBuffer(); try { BufferedReader in = new BufferedReader(new FileReader(fileName)); String s; while ((s = in.readLine()) != null) { if (commentFlag != null && s.trim().startsWith(commentFlag)) { //ignore this line continue; } sb.append(s); //sb.append("/n"); to make it more platform independent (Log July 12, 2004) sb.append(System.getProperty("line.separator")); } in.close(); } catch (IOException ex) { ex.printStackTrace(); System.exit(-1); } return sb; } }