270d0640946d8b44a7e8f84f20b5afcc05138cd2
[nemo.git] / nemo-tools / sandbox / src / main / java / org / opendaylight / nemo / tool / sandbox / utils / FileUtils.java
1 /*
2  * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.nemo.tool.sandbox.utils;
10
11 import java.io.*;
12
13 /**
14  * Created by hj on 12/11/15.
15  */
16 public class FileUtils {
17     public static void write(String path, String content) {
18         try {
19             File f = new File(path);
20             if (!f.exists()) {
21                 if (!f.createNewFile()) {
22                     System.out.println("Can not create new file " + path);
23                 }
24             }
25             BufferedWriter output = new BufferedWriter(new FileWriter(f));
26             output.write(content);
27             output.close();
28         } catch (Exception e) {
29             e.printStackTrace();
30         }
31     }
32 }