public static void delete(File fileOrDir) throws IOException {
        if (fileOrDir == null) {
            return;
        }
        
        if (fileOrDir.isDirectory()) {
            cleanDirectory(fileOrDir);
        } else {
            if (fileOrDir.exists()) {
                boolean isDeleteOk = fileOrDir.delete();
                if (!isDeleteOk) {
                    throw new IOException("delete fail");
                }
            }
        }
    }
@Test
    void testDeleteForDirectory() throws IOException {
        File file = null;
        try {
            String tmpDir = AccessController.doPrivileged(new GetPropertyAction("java.io.tmpdir"));
            File tmpDirFile = new File(tmpDir, "IoUtilsTest");
            tmpDirFile.mkdirs();
            file = File.createTempFile("test_deleteForDirectory", ".txt", tmpDirFile);
            assertTrue(file.exists());
            IoUtils.delete(file.getParentFile());
            assertTrue(tmpDirFile.exists());
            assertFalse(file.exists());
        } finally {
            if (null != file) {
                file.getParentFile().deleteOnExit();
                file.deleteOnExit();
            }
        }
    }