public static void Hash() throws IOException
{
int i = 0;
for (var k : allFiles.keySet())
{
for (var file : allFiles.get(k))
{
FileInputStream fis = new FileInputStream(file.getAbsolutePath());
int b = fis.read();
int xor = 0;
while (b != -1)
{
xor ^= b;
b = fis.read();
}
fis.close();
System.out.println(i++);
System.out.println("End elaboration file " + file.getAbsolutePath());
long xored = file.length() ^ xor;
if (allByHash.get(xored) != null)
{
allByHash.get(xored).add(file);
} else
{
allByHash.put(xored, new LinkedList<File>());
allByHash.get(xored).add(file);
}
}
}
}
It stucks at i = 122; what is wrong? how can it keep looping in the while?
The aim is to read all files byte by byte and compute an hash of their size and content to compare them in search of duplicates.
The method blocks in the while and i can't understand why.
I can't debug the reading of the file byte by byte :p