This week's book giveaway is in the Object Relational Mapping forum. We're giving away four copies of Pro JPA 2: Mastering the Java Persistence API and have Mike Keith and Merrick Schincariol on-line! See this thread for details.
Don't use buf.length but num. num can be smaller than buf.length if there weren't enough bytes available. This way you may write some garbage of a previous read to the MD5 digest, and your length may be too high.