public static void delete(final File file, final boolean ignoreFailures)
    {
        if (file.exists())
        {
            if (file.isDirectory())
            {
                final File[] files = file.listFiles();
                if (null != files)
                {
                    for (final File f : files)
                    {
                        delete(f, ignoreFailures);
                    }
                }
            }

            if (!file.delete() && !ignoreFailures)
            {
                try
                {
                    Files.delete(file.toPath());
                }
                catch (final IOException ex)
                {
                    LangUtil.rethrowUnchecked(ex);
                }
            }
        }
    }
@Test
    void deleteIgnoreFailuresFile() throws IOException
    {
        final Path file = tempDir.resolve("file.txt");
        Files.createFile(file);

        IoUtil.delete(file.toFile(), false);

        assertFalse(Files.exists(file));
    }