code: private static void doCopySmallFile(File source, File destination, boolean append, boolean prependNewLine) throws IOException {
          if (destination.exists() && destination.isDirectory()) {
              throw new IOException("Can not copy file, destination is a directory: " + destination.getAbsolutePath());
          } else if (!destination.exists()) {
              boolean renamed = source.renameTo(destination);
              if (renamed) return;
          }
  
          FileInputStream fis = null;
          FileOutputStream fos = null;
          FileChannel input = null;
          FileChannel output = null;
          long initialSize = destination.length();
          try {
              fos = new FileOutputStream(destination, append);
              if (prependNewLine) {
                  fos.write(("\n").getBytes(StandardCharsets.UTF_8));
              }
              fos.write(Files.readAllBytes(Paths.get(source.getAbsolutePath())));
          } finally {
              closeQuietly(output);
              closeQuietly(input);
              closeQuietly(fis);
              closeQuietly(fos);
          }
          if (!append && destination.length() != source.length()) {
              throw new IOException("Failed to copy content from '" +
                      source + "' (" + source.length() + "bytes) to '" + destination + "' (" + destination.length() + "). isAppend? " + append );
          }
          else if (append && destination.length() <= initialSize ) {
              throw new IOException("Failed to append content from '" +
                      source + "' (" + source.length() + "bytes) to '" + destination + "' (" + destination.length() + "). isAppend? " + append );
          }
  
      }
docs: Simple implementation without chunking if the source file is big.
  
  @param source
  @param destination
  @throws java.io.IOException