Hashes a path, if the path points to a directory then hashes the contents recursively.
@param messageDigest the digest used to hash.
@param path the file/directory we want to hash.
@return the resulting hash.
@throws IOException
496239
public static byte[] hashPath(MessageDigest messageDigest, Path path) throws IOException {
        try (InputStream in = getRecursiveContentStream(path)) {
            return hashContent(messageDigest, in);
        }
    }
690531
public static byte[] messageDigest(String value) {
        MessageDigest md5;
        try {
            md5 = MessageDigest.getInstance("MD5");
            md5.update(value.getBytes("UTF-8"));
            return md5.digest();
        } catch (NoSuchAlgorithmException e) {
            throw new SofaRpcRuntimeException("No such algorithm named md5", e);
        } catch (UnsupportedEncodingException e) {
            throw new SofaRpcRuntimeException("Unsupported encoding of" + value, e);
        }
    }
1090473
def hash_file(filepath: str) -> str:
    """"""
    md5 = hashlib.md5()
    acc_hash(filepath, md5)
    return md5.hexdigest()
938698
public final void writeTo(String path) throws IOException {
        final int i = path.lastIndexOf(DOT);
        if (i < 0 || i + 1 == path.length())
            throw new IOException("Cannot find suffix in provided path: " + path);
        final String fmt = path.substring(i + 1);
        writeTo(fmt, path);
    }
926892
public static HashMap<Integer, Integer> readIntIntMap(Path path, FileSystem fs)
	    throws IOException {
		SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, fs.getConf());

		IntWritable topic = new IntWritable();
		IntWritable value = new IntWritable();

		HashMap<Integer, Integer> ret = new HashMap<Integer, Integer>();

		while(reader.next(topic)) {
			reader.getCurrentValue(value);

			ret.put(topic.get(), value.get());
		}

		reader.close();
		return ret;
	}
313480
public static String readFile(String path) throws IOException {
        if (path.startsWith(ValueConsts.CLASSPATH_PREFIX)) {
            return read(FileExecutor.class.getResourceAsStream(path.substring(ValueConsts.CLASSPATH_PREFIX.length())));
        }
        return readFile(new File(path));
    }
822327
def _hash_file(self, path):
        

        m = hashlib.md5()
        with open(path, "rb") as f:
            while True:
                buf = f.read(128)
                if not buf:
                    break
                m.update(buf)
        return m.hexdigest()
1001862
public static void extractZip(final String path, final File dest) throws IOException {
        extractZip(path, dest, null);
    }
1174251
public RFuture<ByteBuffer> getBytes (final String path) {
    final RPromise<ByteBuffer> result = exec.deferredPromise();
    exec.invokeAsync(new Runnable() {
      public void run () {
        try {
          result.succeed(getBytesSync(path));
        } catch (Throwable t) {
          result.fail(t);
        }
      }
    });
    return result;
  }
280946
public static void ensureDirectoryExists(final Path path) throws IOException {
        if (Files.exists(path)) {
            if (!Files.isDirectory(path)) {
                throw new IOException("path is not a directory: " + path);
            }
            // probably should fsync parent here just to be sure, but that might slow stuff down
        } else {
            Files.createDirectories(path);
            fsyncLineage(path.getParent());
        }
    }
1214319
public static String dirpart(final String path) {
        int s = path.lastIndexOf(File.separatorChar);
        if (s != -1) {
            return path.substring(0, s);
        } else {
            return null;
        } 
    }
50012
public static void deleteRecursively(Path path) throws IOException {
        if (Files.isDirectory(path)) {
            Files.list(path).forEach(file -> {
                try {
                    deleteRecursively(file);
                } catch (IOException e) {
                    throw new UncheckedIOException(e.getMessage(), e);
                }
            });
        }
        Files.delete(path);
    }
760308
public String getBucketId(String path) {
        return String.valueOf(path.toLowerCase(Locale.US).hashCode());
    }
1001323
public static JavaRDD<String> listPaths(JavaSparkContext sc, String path) throws IOException {
        return listPaths(sc, path, false);
    }
397352
public static void deletePathRecursively(String path) throws IOException {
    if (!exists(path)) {
      return;
    }
    Path root = Paths.get(path);
    Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
      @Override
      public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
        Files.delete(file);
        return FileVisitResult.CONTINUE;
      }

      @Override
      public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOException {
        if (e == null) {
          Files.delete(dir);
          return FileVisitResult.CONTINUE;
        } else {
          throw e;
        }
      }
    });
  }
599175
public static byte[] hash(byte[] data, String alg) throws NoSuchAlgorithmException {
		MessageDigest md = MessageDigest.getInstance(alg);
		return md.digest(data);
	}
126656
public static byte[] computeHash(String passwd) throws NoSuchAlgorithmException  {
        java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-1");
        md.reset();
        md.update(passwd.getBytes());
        return md.digest();
    }