// Path: src/main/java/org/fest/util/Arrays.java
// public static <T> boolean isNullOrEmpty(@Nullable T[] array) {
//   return array == null || !hasElements(array);
// }
// 
// Path: src/main/java/org/fest/util/Closeables.java
// public static void closeQuietly(@NotNull Closeable... closeables) {
//   for (Closeable c : closeables) {
//     close(c);
//   }
// }
// 
// Path: src/main/java/org/fest/util/Flushables.java
// public static void flushQuietly(@NotNull Flushable... flushables) {
//   for (Flushable f : flushables) {
//     flush(f);
//   }
// }
// 
// Path: src/main/java/org/fest/util/Preconditions.java
// public static @NotNull <T> T checkNotNull(@Nullable T reference) {
//   if (reference == null) {
//     throw new NullPointerException();
//   }
//   return reference;
// }
// 
// Path: src/main/java/org/fest/util/Strings.java
// public static @NotNull StringToAppend append(@NotNull String toAppend) {
//   return new StringToAppend(toAppend);
// }
// 
// Path: src/main/java/org/fest/util/Strings.java
// public static @Nullable String quote(@Nullable String s) {
//   return s != null ? String.format("'%s'", s) : null;
// }


import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.*;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import static java.io.File.separator;
import static java.lang.String.format;
import static org.fest.util.Arrays.isNullOrEmpty;
import static org.fest.util.Closeables.closeQuietly;
import static org.fest.util.Flushables.flushQuietly;
import static org.fest.util.Preconditions.checkNotNull;
import static org.fest.util.Strings.append;
import static org.fest.util.Strings.quote;
    if (!Strings.isNullOrEmpty(reason)) {
      message = String.format("%s: %s", message, reason);
    }
    return new IORuntimeException(checkNotNull(message), cause);
  }

  /**
   * Flushes and closes the given {@link Writer}. Any I/O errors caught by this method are ignored and not re-thrown.
   *
   * @param writer the writer to flush and close.
   */
  public static void flushAndClose(@Nullable Writer writer) {
    if (writer == null) {
      return;
    }
    flushQuietly(writer);
    closeQuietly(writer);
  }

  /**
   * Flushes and closes the given {@link OutputStream}. Any I/O errors caught by this method are ignored and not
   * re-thrown.
   *
   * @param out the output stream to flush and close.
   */
  public static void flushAndClose(@Nullable OutputStream out) {
    if (out == null) {
      return;
    }
    flushQuietly(out);
// Path: src/main/java/org/fest/util/Arrays.java
// public static <T> boolean isNullOrEmpty(@Nullable T[] array) {
//   return array == null || !hasElements(array);
// }
// 
// Path: src/main/java/org/fest/util/Closeables.java
// public static void closeQuietly(@NotNull Closeable... closeables) {
//   for (Closeable c : closeables) {
//     close(c);
//   }
// }
// 
// Path: src/main/java/org/fest/util/Flushables.java
// public static void flushQuietly(@NotNull Flushable... flushables) {
//   for (Flushable f : flushables) {
//     flush(f);
//   }
// }
// 
// Path: src/main/java/org/fest/util/Preconditions.java
// public static @NotNull <T> T checkNotNull(@Nullable T reference) {
//   if (reference == null) {
//     throw new NullPointerException();
//   }
//   return reference;
// }
// 
// Path: src/main/java/org/fest/util/Strings.java
// public static @NotNull StringToAppend append(@NotNull String toAppend) {
//   return new StringToAppend(toAppend);
// }
// 
// Path: src/main/java/org/fest/util/Strings.java
// public static @Nullable String quote(@Nullable String s) {
//   return s != null ? String.format("'%s'", s) : null;
// }


// Path: src/main/java/org/fest/util/Files.java
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.*;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import static java.io.File.separator;
import static java.lang.String.format;
import static org.fest.util.Arrays.isNullOrEmpty;
import static org.fest.util.Closeables.closeQuietly;
import static org.fest.util.Flushables.flushQuietly;
import static org.fest.util.Preconditions.checkNotNull;
import static org.fest.util.Strings.append;
import static org.fest.util.Strings.quote;

    if (!Strings.isNullOrEmpty(reason)) {
      message = String.format("%s: %s", message, reason);
    }
    return new IORuntimeException(checkNotNull(message), cause);
  }

  /**
   * Flushes and closes the given {@link Writer}. Any I/O errors caught by this method are ignored and not re-thrown.
   *
   * @param writer the writer to flush and close.
   */
  public static void flushAndClose(@Nullable Writer writer) {
    if (writer == null) {
      return;
    }
    flushQuietly(writer);
    closeQuietly(writer);
  }

  /**
   * Flushes and closes the given {@link OutputStream}. Any I/O errors caught by this method are ignored and not
   * re-thrown.
   *
   * @param out the output stream to flush and close.
   */
  public static void flushAndClose(@Nullable OutputStream out) {
    if (out == null) {
      return;
    }
    flushQuietly(out);
    closeQuietly(out);