On 07/08/2011 02:13 PM, Stuart Marks wrote:
On 7/7/11 10:05 PM, Bradford Wetmore wrote:
My only comment is in the diff section. I realize it's a
FileInputStream and
all the bytes should be obtained on a read, but I think you might want to
consider the case of a short read for whatever reason. FileInputStream
doesn't
guarantee that all bytes will be returned, just "some". It might be
better to
read both files until EOF, then compare sizes/contents.
You're correct.
In this vein, it might be reasonable to consider using
java.nio.file.Files.readAllBytes(), which takes a Path and returns a
byte[]. Then simply call Arrays.equals() on the results.
The diff method is now --
private static void diff(String fname1, String fname2) throws Exception {
if (!Arrays.equals(Files.readAllBytes(new File(fname1).toPath()),
Files.readAllBytes(new File(fname2).toPath()))) {
throw new Exception(
"files " + fname1 + " and " + fname2 + " differ");
}
}
I should learn these new JDK 7 classes more. I guess "new
File(f).toPath()" is the most straight forward way to get a Path object?
Thanks
Max
s'marks
Otherwise, looks fine.
Brad
On 6/22/2011 5:48 PM, Weijun Wang wrote:
http://cr.openjdk.java.net/~weijun/6330275/webrev.00/
Thanks
Max
On 06/23/2011 08:03 AM, Brad Wetmore wrote:
No, feel free to take it.
Brad
On 6/21/2011 2:24 AM, Weijun Wang wrote:
Hi Brad
# Timed out, Solaris 10 64bit sparcv9
com/sun/crypto/provider/Cipher/DES/PaddingTest.java generic-all
This test has not generated random numbers (all key material in
byte[]
constants) so there is no entropy pool issue. One special thing is
that
it calls the external diff command on two files but only prints
out the
result with no exception thrown when the files are different
(6330275).
I see you're RE for . Are you working on it now?
Thanks
Max