public static void deleteRecursively(File file) throws IOException {
        if (file == null) {
            return;
        }

        if (file.isDirectory() && !isSymlink(file)) {
            IOException savedIOException = null;
            for (File child : listFilesSafely(file)) {
                try {
                    deleteRecursively(child);
                } catch (IOException e) {
                    // In case of multiple exceptions, only last one will be thrown
                    savedIOException = e;
                }
            }
            if (savedIOException != null) {
                throw savedIOException;
            }
        }

        boolean deleted = file.delete();
        // Delete can also fail if the file simply did not exist.
        if (!deleted && file.exists()) {
            throw new IOException("Failed to delete: " + file.getAbsolutePath());
        }
    }
Convert the given byte buffer to a string. The resulting string can be
converted back to the same byte buffer through {@link #stringToBytes(String)}.
indexr-query-opt/src/main/java/org/apache/spark/util/JavaUtils.java