3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.sal.utils;
12 import java.util.ArrayList;
16 * Convenience object for reading from file
21 public class ReadFromFile {
22 private FileInputStream fileStream;
23 private File filePointer;
25 public ReadFromFile(String fileName) throws FileNotFoundException {
26 fileStream = new FileInputStream(fileName);
27 filePointer = new File(fileName); //needed to allow file deletion
30 public ArrayList<String> readFile() throws IOException {
31 DataInputStream dataInput = new DataInputStream(this.fileStream);
32 BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(dataInput));
34 ArrayList<String> lineList = new ArrayList<String>();
36 while ((line = bufferedReader.readLine()) != null) {
39 bufferedReader.close();
45 public boolean delete() {
46 if (filePointer == null) {
49 return filePointer.delete();