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;
13 import java.util.ArrayList;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
19 * Convenience object to write a file
24 public class WriteToFile {
25 protected static final Logger logger = LoggerFactory
26 .getLogger(WriteToFile.class);
27 private FileWriter fstream;
28 private BufferedWriter bufferOut;
29 private String fileName;
31 public WriteToFile(String name) throws IOException {
33 fstream = new FileWriter(fileName);
34 bufferOut = new BufferedWriter(fstream);
37 public void save(ArrayList<String> entryList) throws IOException {
38 for (String entry : entryList) {
39 bufferOut.write(entry);
40 bufferOut.append('\n');
43 this.bufferOut.flush();
44 } catch (IOException e) {
49 public boolean close() {
53 } catch (IOException e) {