?
=?iso-8859-1?B?QmVub+50?=
Hi
I want to compare two big files (like films), so I create a fingerprint
and I look...
It works very well with little files, but a java.lang.outOfMemory
appears with big files...
I think the array data in readFile(String filename) function is too
big...so how do I do?
try {
byte[] data = readFile(myfile.getAbsolutePath());
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(data);
byte[] digest = md.digest();
System.out.println("Hexadecimal: " + myfile.getAbsolutePath()+new
BigInteger(digest).toString(16));
}catch (Exception e) {
System.out.println(e);
}
....
private static byte[] readFile(String filename) {
try {
RandomAccessFile raf = new RandomAccessFile(filename, "r");
byte[] data = new byte[(int)raf.length()];
raf.readFully(data);
raf.close();
System.out.println("He");
return data;
}
catch (FileNotFoundException e) {}
catch (IOException e) {}
return null;
}
Thanks
I want to compare two big files (like films), so I create a fingerprint
and I look...
It works very well with little files, but a java.lang.outOfMemory
appears with big files...
I think the array data in readFile(String filename) function is too
big...so how do I do?
try {
byte[] data = readFile(myfile.getAbsolutePath());
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(data);
byte[] digest = md.digest();
System.out.println("Hexadecimal: " + myfile.getAbsolutePath()+new
BigInteger(digest).toString(16));
}catch (Exception e) {
System.out.println(e);
}
....
private static byte[] readFile(String filename) {
try {
RandomAccessFile raf = new RandomAccessFile(filename, "r");
byte[] data = new byte[(int)raf.length()];
raf.readFully(data);
raf.close();
System.out.println("He");
return data;
}
catch (FileNotFoundException e) {}
catch (IOException e) {}
return null;
}
Thanks