File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to check if file contents read matches what was written

 
John Vorwald
Ranch Hand
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to check if the data read from a file is the same as what was written.
Does the following example which calculating, saves, reads, recalculates, and compares the hash code accomplish the goal of making sure the data read matches the data written?
Is there a simpler solution?




 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's actually pretty tough to read.

And what's up with your naming conventions? Does an "f" in front of a name mean something or not? If so, what on earth does it mean? What's the "a" prefix, in things like "aAValue"? What's with the comments of "Read data from a binary file" on a method named "readBinaryFile"? And naming an ObjectInputStream aIsObject? It's all quite distracting.

So, my two questions would be these: (a) does it do what you want, and (b) how could it be simpler than writing, reading, and comparing?
 
Rob Spoor
Sheriff
Pie
Posts: 20388
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:And what's up with your naming conventions? Does an "f" in front of a name mean something or not? If so, what on earth does it mean? What's the "a" prefix, in things like "aAValue"?

That's how some people name their variables: f for fields, a for arguments, nothing for local variables. I find it highly distracting too.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:That's how some people name their variables: f for fields, a for arguments, nothing for local variables. I find it highly distracting too.

It's not very consistent in the code above, which is one reason I asked.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic