@@ -0,0 +1,2544 @@
+package net.java.sen.util;%0A%0Aimport java.io.Closeable;%0Aimport java.io.IOException;%0Aimport java.lang.reflect.Method;%0A%0A/**%0A * a subset of org.apache.lucene.util.IOUtils.%0A *%0A */%0Apublic class IOUtils %7B%0A  /** This reflected %7B@link Method%7D is %7B@code null%7D before Java 7 */%0A  private static final Method SUPPRESS_METHOD;%0A  static %7B%0A    Method m;%0A    try %7B%0A      m = Throwable.class.getMethod(%22addSuppressed%22, Throwable.class);%0A    %7D catch (Exception e) %7B%0A      m = null;%0A    %7D%0A    SUPPRESS_METHOD = m;%0A  %7D%0A%0A  /**%0A   * Closes all given %3Ctt%3ECloseable%3C/tt%3Es.  Some of the%0A   * %3Ctt%3ECloseable%3C/tt%3Es may be null; they are%0A   * ignored.  After everything is closed, the method either%0A   * throws the first exception it hit while closing, or%0A   * completes normally if there were no exceptions.%0A   * %0A   * @param objects%0A   *          objects to call %3Ctt%3Eclose()%3C/tt%3E on%0A   */%0A  public static void close(Closeable... objects) throws IOException %7B%0A    Throwable th = null;%0A%0A    for (Closeable object : objects) %7B%0A      try %7B%0A        if (object != null) %7B%0A          object.close();%0A        %7D%0A      %7D catch (Throwable t) %7B%0A        addSuppressed(th, t);%0A        if (th == null) %7B%0A          th = t;%0A        %7D%0A      %7D%0A    %7D%0A%0A    if (th != null) %7B%0A      if (th instanceof IOException) throw (IOException) th;%0A      if (th instanceof RuntimeException) throw (RuntimeException) th;%0A      if (th instanceof Error) throw (Error) th;%0A      throw new RuntimeException(th);%0A    %7D%0A  %7D%0A  /**%0A   * Closes all given %3Ctt%3ECloseable%3C/tt%3Es, suppressing all thrown exceptions.%0A   * Some of the %3Ctt%3ECloseable%3C/tt%3Es may be null, they are ignored.%0A   * %0A   * @param objects%0A   *          objects to call %3Ctt%3Eclose()%3C/tt%3E on%0A   */%0A  public static void closeWhileHandlingException(Closeable... objects) throws IOException %7B%0A    for (Closeable object : objects) %7B%0A      try %7B%0A        if (object != null) %7B%0A          object.close();%0A        %7D%0A      %7D catch (Throwable t) %7B%0A      %7D%0A    %7D%0A  %7D%0A  /** adds a Throwable to the list of suppressed Exceptions of the first Throwable (if Java 7 is detected)%0A   * @param exception this exception should get the suppressed one added%0A   * @param suppressed the suppressed exception%0A   */%0A  private static final void addSuppressed(Throwable exception, Throwable suppressed) %7B%0A    if (SUPPRESS_METHOD != null && exception != null && suppressed != null) %7B%0A      try %7B%0A        SUPPRESS_METHOD.invoke(exception, suppressed);%0A      %7D catch (Exception e) %7B%0A        // ignore any exceptions caused by invoking (e.g. security constraints)%0A      %7D%0A    %7D%0A  %7D%0A  %0A%7D%0A

add net.java.sen.util.IOUtils.