Here you can find the source of md5(InputStream is)
private static String md5(InputStream is) throws Exception
//package com.java2s; /******************************************************************************* * Copyright (c) 2009 Richard Malek and SEAGE contributors //w ww . j a va 2 s . c om * This file is part of SEAGE. * SEAGE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * SEAGE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with SEAGE. If not, see <http://www.gnu.org/licenses/>. * */ import java.io.InputStream; import java.math.BigInteger; import java.security.MessageDigest; public class Main { private static String md5(InputStream is) throws Exception { MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] buffer = new byte[8192]; int read = 0; while ((read = is.read(buffer)) > 0) { digest.update(buffer, 0, read); } byte[] md5sum = digest.digest(); BigInteger bigInt = new BigInteger(1, md5sum); String output = bigInt.toString(16); is.close(); return output; } }