private static String bufferToHex(byte bytes[], int m, int n) { StringBuffer stringbuffer = new StringBuffer(2 * n); int k = m + n; for (int l = m; l < k; l++) { appendHexPair(bytes[l], stringbuffer); } return stringbuffer.toString(); } private static void appendHexPair(byte bt, StringBuffer stringbuffer) {
private static String bufferToHex(byte bytes[]) { return bufferToHex(bytes, 0, bytes.length); } private static String bufferToHex(byte bytes[], int m, int n) {
public static boolean compareFiles(File one, File two) throws IOException { if (one.getAbsolutePath().equals(two.getAbsolutePath())) { // 是同一个文件 return true; } String md5_1 = getFileMD5String(one); String md5_2 = getFileMD5String(two); return TextUtils.equals(md5_1, md5_2); }
public static String getFileMD5String(InputStream in) throws IOException { byte[] buffer = new byte[1024]; int numRead; while ((numRead = in.read(buffer)) > 0) { MESSAGE_DIGEST_5.update(buffer, 0, numRead); } in.close(); return bufferToHex(MESSAGE_DIGEST_5.digest()); } private static String bufferToHex(byte bytes[]) {
public static boolean compareFiles(File one, File two) throws IOException { if (one.getAbsolutePath().equals(two.getAbsolutePath())) { // 是同一个文件 return true; } String md5_1 = getFileMD5String(one); String md5_2 = getFileMD5String(two); return TextUtils.equals(md5_1, md5_2); }
private static String bufferToHex(byte bytes[], int m, int n) { StringBuffer stringbuffer = new StringBuffer(2 * n); int k = m + n; for (int l = m; l < k; l++) { appendHexPair(bytes[l], stringbuffer); } return stringbuffer.toString(); } private static void appendHexPair(byte bt, StringBuffer stringbuffer) {
public static String getFileMD5String(File file) throws IOException { InputStream fis; fis = new FileInputStream(file); byte[] buffer = new byte[1024]; int numRead; while ((numRead = fis.read(buffer)) > 0) { MESSAGE_DIGEST_5.update(buffer, 0, numRead); } fis.close(); return bufferToHex(MESSAGE_DIGEST_5.digest()); }
public static boolean compareFiles(File one, File two) throws IOException { if (one.getAbsolutePath().equals(two.getAbsolutePath())) { // 是同一个文件 return true; } String md5_1 = getFileMD5String(one); String md5_2 = getFileMD5String(two); return TextUtils.equals(md5_1, md5_2); }
private static String bufferToHex(byte bytes[], int m, int n) { StringBuffer stringbuffer = new StringBuffer(2 * n); int k = m + n; for (int l = m; l < k; l++) { appendHexPair(bytes[l], stringbuffer); } return stringbuffer.toString(); } private static void appendHexPair(byte bt, StringBuffer stringbuffer) {
private static String bufferToHex(byte bytes[]) { return bufferToHex(bytes, 0, bytes.length); } private static String bufferToHex(byte bytes[], int m, int n) {
private static String bufferToHex(byte bytes[]) { return bufferToHex(bytes, 0, bytes.length); } private static String bufferToHex(byte bytes[], int m, int n) {
public static String getFileMD5String(File file) throws IOException { InputStream fis; fis = new FileInputStream(file); byte[] buffer = new byte[1024]; int numRead; while ((numRead = fis.read(buffer)) > 0) { MESSAGE_DIGEST_5.update(buffer, 0, numRead); } fis.close(); return bufferToHex(MESSAGE_DIGEST_5.digest()); }
public static String getFileMD5String(InputStream in) throws IOException { byte[] buffer = new byte[1024]; int numRead; while ((numRead = in.read(buffer)) > 0) { MESSAGE_DIGEST_5.update(buffer, 0, numRead); } in.close(); return bufferToHex(MESSAGE_DIGEST_5.digest()); } private static String bufferToHex(byte bytes[]) {
public static String getFileMD5String(InputStream in) throws IOException { byte[] buffer = new byte[1024]; int numRead; while ((numRead = in.read(buffer)) > 0) { MESSAGE_DIGEST_5.update(buffer, 0, numRead); } in.close(); return bufferToHex(MESSAGE_DIGEST_5.digest()); } private static String bufferToHex(byte bytes[]) {
public static String getFileMD5String(File file) throws IOException { InputStream fis; fis = new FileInputStream(file); byte[] buffer = new byte[1024]; int numRead; while ((numRead = fis.read(buffer)) > 0) { MESSAGE_DIGEST_5.update(buffer, 0, numRead); } fis.close(); return bufferToHex(MESSAGE_DIGEST_5.digest()); }