• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (C) 2011 The Libphonenumber Authors
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *       http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  *  under the License.
16  */
17 
18 package com.google.i18n.phonenumbers;
19 
20 import java.io.Closeable;
21 import java.io.IOException;
22 
23 /**
24  * Helper class containing methods designed to ease file manipulation and generation.
25  *
26  * @author Philippe Liard
27  */
28 public class FileUtils {
29   /**
30    * Silently closes a resource (i.e: don't throw any exception).
31    */
close(Closeable closeable)32   private static void close(Closeable closeable) {
33     if (closeable == null) {
34       return;
35     }
36     try {
37       closeable.close();
38     } catch (IOException e) {
39       System.err.println(e.getMessage());
40     }
41   }
42 
43   /**
44    * Silently closes multiple resources. This method doesn't throw any exception when an error
45    * occurs when a resource is being closed.
46    */
closeFiles(Closeable .... closeables)47   public static void closeFiles(Closeable ... closeables) {
48     for (Closeable closeable : closeables) {
49       close(closeable);
50     }
51   }
52 }
53