// 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;
    return file;
  }

  private static @NotNull IORuntimeException cannotCreateNewFile(@NotNull String path, @NotNull String reason) {
    throw cannotCreateNewFile(path, reason, null);
  }

  private static @NotNull IORuntimeException cannotCreateNewFile(@NotNull String path, @NotNull IOException cause) {
    throw cannotCreateNewFile(path, null, cause);
  }

  private static @NotNull IORuntimeException cannotCreateNewFile(
          @NotNull String path, @Nullable String reason, @Nullable IOException cause) {
    String message = String.format("Unable to create the new file %s", quote(path));
    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);
// 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;

    return file;
  }

  private static @NotNull IORuntimeException cannotCreateNewFile(@NotNull String path, @NotNull String reason) {
    throw cannotCreateNewFile(path, reason, null);
  }

  private static @NotNull IORuntimeException cannotCreateNewFile(@NotNull String path, @NotNull IOException cause) {
    throw cannotCreateNewFile(path, null, cause);
  }

  private static @NotNull IORuntimeException cannotCreateNewFile(
          @NotNull String path, @Nullable String reason, @Nullable IOException cause) {
    String message = String.format("Unable to create the new file %s", quote(path));
    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);