19 package org.sleuthkit.autopsy.modules.hashdatabase;
21 import java.io.BufferedReader;
23 import java.io.FileReader;
24 import java.io.FileNotFoundException;
25 import java.io.IOException;
26 import java.util.logging.Level;
34 class IdxHashSetParser
implements HashSetParser {
36 private final String filename;
37 private BufferedReader reader;
38 private final long totalHashes;
39 private boolean doneReading =
false;
41 IdxHashSetParser(String filename)
throws TskCoreException {
42 this.filename = filename;
44 reader =
new BufferedReader(
new FileReader(filename));
45 }
catch (FileNotFoundException ex) {
46 throw new TskCoreException(
"Error opening file " + filename, ex);
50 File importFile =
new File(filename);
51 long fileSize = importFile.length();
52 totalHashes = fileSize / 0x33 + 1;
64 public String getNextHash() throws TskCoreException {
68 while ((line = reader.readLine()) != null) {
71 String[] parts = line.split(
"\\|| ");
73 String hashStr = parts[0].toLowerCase();
74 if (!hashStr.matches(
"^[0-9a-f]{32}$")) {
80 }
catch (IOException ex) {
81 throw new TskCoreException(
"Error reading file " + filename, ex);
95 public boolean doneReading() {
106 public long getExpectedHashCount() {
114 public void close() {
117 }
catch (IOException ex) {
118 Logger.getLogger(IdxHashSetParser.class.getName()).log(Level.SEVERE,
"Error closing file " + filename, ex);