SilentFileInputStream.java

  1. /*
  2.  * Copyright (C) 2018, David Pursehouse <david.pursehouse@gmail.com> and others
  3.  *
  4.  * This program and the accompanying materials are made available under the
  5.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  6.  * https://www.eclipse.org/org/documents/edl-v10.php.
  7.  *
  8.  * SPDX-License-Identifier: BSD-3-Clause
  9.  */

  10. package org.eclipse.jgit.util.io;

  11. import java.io.File;
  12. import java.io.FileInputStream;
  13. import java.io.FileNotFoundException;
  14. import java.io.IOException;

  15. /**
  16.  * An implementation of FileInputStream that ignores any exceptions on close().
  17.  *
  18.  * @since 5.0
  19.  */
  20. public class SilentFileInputStream extends FileInputStream {
  21.     /**
  22.      * @param file
  23.      *            the file
  24.      * @throws FileNotFoundException
  25.      *             the file was not found
  26.      */
  27.     public SilentFileInputStream(File file) throws FileNotFoundException {
  28.         super(file);
  29.     }

  30.     @Override
  31.     public void close() {
  32.         try {
  33.             super.close();
  34.         } catch (IOException e) {
  35.             // Ignore
  36.         }
  37.     }
  38. }