Mark AD-SAL interfaces as deprecated
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / utils / ReadFromFile.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 package org.opendaylight.controller.sal.utils;
11
12 import java.io.BufferedReader;
13 import java.io.DataInputStream;
14 import java.io.File;
15 import java.io.FileInputStream;
16 import java.io.FileNotFoundException;
17 import java.io.IOException;
18 import java.io.InputStreamReader;
19 import java.util.ArrayList;
20
21 /**
22  * Convenience object for reading from file
23  *
24  *
25  *
26  */
27 @Deprecated
28 public class ReadFromFile {
29     private FileInputStream fileStream;
30     private File filePointer;
31
32     public ReadFromFile(String fileName) throws FileNotFoundException {
33         fileStream = new FileInputStream(fileName);
34         filePointer = new File(fileName); //needed to allow file deletion
35     }
36
37     public ArrayList<String> readFile() throws IOException {
38         DataInputStream dataInput = new DataInputStream(this.fileStream);
39         BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(dataInput));
40
41         ArrayList<String> lineList = new ArrayList<String>();
42         String line;
43         while ((line = bufferedReader.readLine()) != null) {
44             lineList.add(line);
45         }
46         bufferedReader.close();
47         dataInput.close();
48         fileStream.close();
49         return lineList;
50     }
51
52     public boolean delete() {
53         if (filePointer == null) {
54             return true;
55         }
56         return filePointer.delete();
57     }
58 }