private static File[] listFilesSafely(File file) throws IOException {
        if (file.exists()) {
            File[] files = file.listFiles();
            if (files == null) {
                throw new IOException("Failed to list files for dir: " + file);
            }
            return files;
        } else {
            return new File[0];
        }
    }
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