1/* 2 * Copyright (C) 2015 The Android Open Source Project 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 */ 16 17package android.support.provider; 18 19import android.support.annotation.Nullable; 20import android.support.annotation.RestrictTo; 21 22import java.io.Closeable; 23import java.io.InputStream; 24import java.util.Collection; 25 26import static android.support.annotation.RestrictTo.Scope.GROUP_ID; 27 28/** 29 * Simple static methods to perform common IO operations. 30 * @hide 31 */ 32@RestrictTo(GROUP_ID) 33final class IoUtils { 34 static void closeQuietly(@Nullable Closeable closeable) { 35 if (closeable != null) { 36 try { 37 closeable.close(); 38 } catch (RuntimeException e) { 39 throw e; 40 } catch (Exception e) { 41 // Ignore. 42 } 43 } 44 } 45 46 static void closeQuietly(@Nullable InputStream stream) { 47 if (stream != null) { 48 try { 49 stream.close(); 50 } catch (RuntimeException e) { 51 throw e; 52 } catch (Exception e) { 53 // Ignore. 54 } 55 } 56 } 57} 58