2 package org
.de
.metux
.util
;
4 import java
.util
.Hashtable
;
5 import java
.util
.Enumeration
;
6 import java
.io
.IOException
;
8 import java
.io
.FileNotFoundException
;
9 import java
.io
.BufferedReader
;
10 import java
.io
.FileReader
;
12 public class FileStock
27 public String
getmd5(String fn
)
29 return getmd5(new File(fn
));
32 public String
getmd5(File f
)
34 return FileOps
.md5(f
);
37 private void add(record r_new
)
41 if ((r_old
= (record
)ht
.get(r_new
.md5
))==null)
43 ht
.put(r_new
.md5
,r_new
);
47 if (r_new
.md5
.equals(r_old
.md5
))
50 throw new RuntimeException("COLLISSION "+r_old
.filename
+" vs. "+r_new
.filename
);
53 public void add(String
[] fns
)
54 throws FileNotFoundException
, IOException
59 for (int x
=0; x
<fns
.length
; x
++)
63 public void add(String fn
)
64 throws FileNotFoundException
, IOException
66 record r
= new record();
72 public String
[] getFilenames()
74 int count
= ht
.size();
75 String fns
[] = new String
[count
];
78 for (Enumeration e
=ht
.keys(); e
.hasMoreElements(); )
80 record r
= (record
)ht
.get((String
)e
.nextElement());
81 fns
[x
++] = r
.filename
;
83 System
.runFinalization();