Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / utils / WriteToFile.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.BufferedWriter;
13 import java.io.FileWriter;
14 import java.io.IOException;
15 import java.util.ArrayList;
16
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 /**
21  * Convenience object to write a file
22  *
23  *
24  *
25  */
26 @Deprecated
27 public class WriteToFile {
28     protected static final Logger logger = LoggerFactory
29     .getLogger(WriteToFile.class);
30     private FileWriter fstream;
31     private BufferedWriter bufferOut;
32
33     public WriteToFile(String fileName) throws IOException {
34         fstream = new FileWriter(fileName);
35         bufferOut = new BufferedWriter(fstream);
36     }
37
38     public void save(ArrayList<String> entryList) throws IOException {
39         for (String entry : entryList) {
40             bufferOut.write(entry);
41             bufferOut.append('\n');
42         }
43         try {
44             this.bufferOut.flush();
45         } catch (IOException e) {
46             logger.error("",e);
47         }
48     }
49
50     public boolean close() {
51         try {
52             bufferOut.close();
53             fstream.close();
54         } catch (IOException e) {
55             return false;
56         }
57         return true;
58     }
59 }