I'm trying to find the checksum but I keep getting a 9 digit number??

I'm trying to write a method that will return the checksum of a file that is passed to it. I would like to compare this checksum to the checksum of a file stored in SVN source control. So far I have this bit of code that I'v cobbled together:
import java.io.*;
import java.util.zip.CheckedInputStream;
import java.util.zip.CRC32;
public class CreateCheckSumOfFile
    public long checkSum(String filePath)
     long checksum = 0;
        FileInputStream file = new FileInputStream(filePath);
        CheckedInputStream check = new CheckedInputStream(file, new CRC32());
        BufferedInputStream in = new BufferedInputStream(check);
        while (in.read() != -1)
            // Read file in completely
        checksum = check.getChecksum().getValue();
        return checksum;   
}I've tried a number of variations however I keep getting a 9 digit number. Why am I not receiving a 32 digit number? Since the checksum is a hexidecimal number shouldn't I be using a String? Any other pointers would be appreciated. Thanks.

Yes thanks you are correct. I was suppose to be calculating a md5sum. I didn't realize there was a difference. I've done some more searching and I've cobbled together some code that is working for me. I've created a method that receives a file path and then returns the md5sum of that file. The md5sums that this produced matched the ones generated by the perl md5sum.exe.
package createchecksumoffile;
import java.io.*;
import java.security.MessageDigest;
public class CreateCheckSumOfFile
    public static void main(String[] args) throws Exception
     String filePath = "Enter your file path";
     String checksum = getMD5Checksum(filePath);
     System.out.println();
     System.out.println("Check Sum of: " + filePath);
     System.out.println(checksum);
     System.out.println();     
    public static String getMD5Checksum(String filePath) throws Exception
     InputStream fileInputStream =  new FileInputStream(filePath);
     byte[] buffer = new byte[1024];
     MessageDigest complete = MessageDigest.getInstance("MD5");
     int numRead;
     do{
         numRead = fileInputStream.read(buffer);
         if (numRead > 0)
          complete.update(buffer, 0, numRead);
     }while (numRead != -1);
     fileInputStream.close();     
     String result = "";
     buffer = complete.digest();
     for (int i=0; i < buffer.length; i++)
         result += Integer.toString( ( buffer[i] & 0xff ) + 0x100, 16).substring( 1 );
     return result;
}I hope this is helpful for someone else. I am very open to criticism of this. The only question I had was about the line:
"byte[] buffer = new byte[1024]"
Does this line create some type of file size limitation?

Similar Messages

  • I'm trying to up grade the os but I keep getting the startup disk is full I ordered more memory I was told this will not help. What do I do?

    I'm trying to up grade the os but I keep getting the startup disk is full I ordered more memory I was told this will not help. What do I do?

    I think as drive capacities increase, the old 10-15% becomes less accurate.  The amount of free space you need doesn't really have anything to do with the drive size.  So, increasing your drive size shouldn't mean that you need to have more free GB (which using a % of drive space would mean).  You need free space to accommodate page outs (the amount of which would depend on how much RAM you have installed and how memory intensive the applications are), sleep images (again, this would max out at your total amount of RAM), and a bit to minimize fragmentation.
    With desktop drives commonly in the 2TB range today, it is certainly not necessary to have 200GB+ free in order to maintain proper operation.  I generally find about 30GB to be the minimum I'm comfortable with.  Mind you, I pretty much always have way more than that available.  But, if I'm working on a system and the amount of free space is at least 30GB, I would generally not site drive space as the cause of any performance issues.  I'd say that 30GB is a minimum for a stable system (with 8GB or RAM installed).  Of course at that amount, you would still need to free up space if you were to want to install or download any significant amount of data.
    With servers being more likely to run into the 16GB of RAM range, more storage would be necessary.  Most servers should be well stocked with storage, but the actual needs would vary greatly depending on what's being "served".
    The 10-15% thing came about when we used to talk about drive capacities in hundreds of MBs and RAM in terms of KB (not MB and certainly not GB).  More drive space is always a good thing, but as drive capacities continue to sky rocket, we don't need to dedicate larger amounts of storage on systems with the same specifications.  A set amount of space is required for proper operation regardless of the capacity of the drive installed.

  • My iphone 4s has the connect to itunes screen. I have tried to reset, recover, etc but I keep getting and error-51 message. Any ideas how I can get my phone working again? I am not worried about saving any info just having a phone to use!

    I was in the middle of the iOS 8 update and tried to turn my phone off (yes, I realize this was dumb) But what happened was it tried to reset. Now,  my iphone 4s has the connect to itunes screen. I have tried to reset, recover, etc but I keep getting and error -51 message. Any ideas how I can get my phone working again? I am not worried about saving any info just having a phone to use!

    Try a Hard Reset.....
    Press and hold the Wake / Sleep button AND the Home button at the same time, keep them both pressed until the Apple Logo appears on the screen, it can take 10 or more seconds.  Ignore the swipe to turn off message.

  • HT1338 My computer says it's connected to the internet, but I keep getting a message that my computer can't find the server.

    My computer says it's connected to the internet, but I keep getting a message that my computer can't find the server.  Could there be a problem with my computer's internet connection?

    First, unplug the modem, for at least 10 secs., then unlpug you airport/ wifi/ then try to reconnect.
    If it it does not not work, reconnect your modem, then reconnect your network utilites, use assistance.

  • TS3212 I tried to update my iTunes, but I keep getting a runtime error  R6034 Attempt to run C runtime library incorrectly.    I also got an Error 7 (Windows error 1114)

    I tried to update my iTunes, but I keep getting a runtime error R6034 attempt to run C runtime library incorrectly.  I also got an Error 7 (Windows error 1114).  Now my currently iTunes will not open.

    Hey twhitten!
    Here is an article that will help you troubleshoot this issue:
    iTunes 11.1.4 for Windows: Unable to install or open
    http://support.apple.com/kb/TS5376
    Take care, and thanks for visiting the Apple Support Communities.
    Cheers,
    Braden

  • HT201210 I,m trying to restore my phone but I keep getting Error code 21.... help please

    I,m trying to restore my phone but I keep getting Error code 21.... help please     iPhone 4S

    Take a look at this Apple doc -> iTunes: Specific update-and-restore error messages and advanced troubleshooting
    Error 20, 21, 23, 26, 28, 29, 34, 36, 37, 40
    These errors typically occur when security software interferes with the restore and update process. Follow Troubleshooting security software issues to resolve this issue. In rare cases, these errors may be a hardware issue. If the errors persist on another computer, the device may need service.
    Also, check your hosts file to verify that it's not blocking iTunes from communicating with the update server. See iTunes: Advanced iTunes Store troubleshooting—follow steps under the heading Blocked by configuration (Mac OS X / Windows) > Rebuild network information > Mac OS X > The hosts file may also be blocking the iTunes Store. If you have software used to perform unauthorized modifications to the iOS device, uninstall this software prior to editing the hosts file to prevent that software from automatically modifying the hosts file again on restart.
    You could just update or uninstall the security software on your computer and then test again.

  • I am trying to update an app but i keep getting a messages saying "your apple ID has been disabled".

    I am trying to update an app but i keep getting the message "Your Apple ID has been disabled". What do I do? How can I fix this? My Apple ID works on my mac fine. Help please!

    How to report an issue with your iTunes Store purchase - http://support.apple.com/kb/HT1933 - working through iTunes application and iTunes Store interface.
    iTunes Customer Service Contact - http://www.apple.com/support/itunes/contact.html

  • Trying to download mountain lion but just keep getting calculating coming up

    trying to download mountain lion but just keep getting calculating appearing

    Try to grab it from a test User Account.
    Mac OS X 10.6: Creating a new user account
              http://support.apple.com/kb/PH6651

  • I'm trying to download a movie, but I keep getting message error that I have no more room and that I must delete some photos or videos in order to download more movies. How do I delete the videos in order to order more?

    I'm trying to purchase and download a movie, but I keep getting message error that I have no space. The error states that I must delete some photos or videos in order to download. I've gone to iPod then edit and deleted some videos, but I'm still getting the message. What is the correct way to delete the videos and should they still be there.

    They wont still be there if you delete them,but if you have those same photos on the main computer.

  • I closed Firefox and tried to re-open it, but I keep getting a message that says "A copy of Firefox is already open. Only one copy of Firefox can be open at a time." Help!

    My Mac laptop was working very slowly. I closed it but I can't re-open the version I had. I tried to move it to the trash and download a new version but, I keep getting the same message. How can I get rid of this copy and get back to work????

    See:
    * https://support.mozilla.com/kb/Firefox+is+already+running+but+is+not+responding

  • TS3694 i am trying to restore my iphone4 but i keep getting an error 3194 message, what do i need to do?

    My phone crashed during a software update and when i try to restore it on the itunes site, i keep getting an error 3194 message. It is an iphone4, what can i do?

    This usually means you previously used an iPhone hacking utility such as tinyumbrella which altered your computer hosts file, blocking access to the Apple server, gs.apple.com:
    Error 1004, 1013, 1638, 3194: These errors may be the result of the connection to gs.apple.com being redirected or blocked. Follow these steps to resolve these errors:
    Install the latest version of iTunes.
    Check security software. Ensure that communication to gs.apple.com is allowed. Follow this article for assistance with security software. iTunes for Windows: Troubleshooting security software issues.
    Check the hosts file. The restore will fail if there is an active entry to redirect gs.apple.com. FollowiTunes: Advanced iTunes Store troubleshooting to edit the hosts file or revert to a default hosts file. See section "Blocked by configuration: (Mac OS X/Windows) > Rebuild network information".
    Try to restore from another known-good computer and network.
    If the errors persist on another computer, the device may need service.

  • HT4061 i found a i phone 3g i am trying to find the owner but i cant i have no password

    i found a iphone and i am trying to find who it belongs to so can return it but it is locked and i dont know the passcode please help
                                           Thank you

    Turn it in to the police. They can contact Apple and possibly find the owner.

  • Trying to download latest iTunes, but I keep getting "The older version of Apple Software Update cannot be removed.  Contact your technical support group."  Please help.

    Please help.  I am trying to download the latest version of iTunes so I can synch my new iPhone.  I keep getting "The older version of Apple Software Update cannot be removed.  Contact your technical support group."  Please help as I have absolutely no idea.  Thanks.

    Download the Windows Installer CleanUp utility from the following page (use one of the links under the thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    To install the utility, doubleclick the msicuu2.exe file you downloaded.
    Now run the utility ("Start > All Programs > Windows Install Clean Up"). In the list of programs that appears in CleanUp, select any Apple Software Update entries and click "Remove", as per the following screenshot:
    Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • Hello I use Mac pro with OSX 10.9.9 I am trying to download flash player but I keep getting this "Install Adobe Flashplayer" is Damaged and can't be opened anyone got any ideas please

    Hello I use a macbook pro with OSX 10.9.5. I am trying to download Flash player but keep getting this message "Install Adobe Flashplayer" is damaged and can't be opened.You should eject the disk image.Any ideas please?

    You should make sure you do a complete uninstall of the flash player first and then install the latest FP14 version from this link - Use http://download.macromedia.com/pub/flashplayer/current/support/install_flash_player_osx.dm g
    In order to do a complete uninstall - Uninstall Flash Player | Mac OS

  • I'm trying to reinstall my Itunes, but I keep getting a error message stating that itunemsi can't be found

    I was trying to sync my Ipod and kept getting a error message saying that I could'nt because the file could not be found. so I went to Itunes Support And was instructed to reinstall  Itunes, and I followed the installation instructions. Well then I got another error message saying Itunesmsi can not be found. So if anyone knows where I would find the installation Package no my computer.
                                                                          Thanks
                                                                          Signed Frustraed

    Could any of the music have been sourced on an external USB drive or a network drive? In iTunes, go to one of the songs that won't sync. Bring up the info page, and look at the location of that song on the disk. Does that file and path exist? That could be your problem, especially if they were on a USB drive you forgot about.

Maybe you are looking for

  • BBZ10 and Q10 key Features.

    Here are some key features of Blackberry Z10 and Q10: 1) The Z10 which has a 4.2-inch screen(1,280 x 768 display), will be sold at an unsubsidized price of $599, but can be obtained through some carriers for $149 with a three-year contract. Pricing f

  • No mapping found for '

    Hi, I am using JDeveloper 9.0.3.11.18(Build 1247) for WS. We have generated a stub from our web services. Generation and compilation is not a problem. I have tested the web service from the end point, its working properly. When I am calling the stub

  • Error message in java console

    I am wondering if any of you can help me. My live scoring on my fantasy baseball site won't keep up to the minute stats, and I keep getting the following error message in my java console: Host Name: fdjs.baseball.sportsline.com Error loading class: z

  • File corrupted help

    so i just purchased an album off the itunes store and it downloaded fine. but the 2nd song on the album won't download and it says file may be corrupted err -100000.  so i called the customer support line and after being tossed around for a half hour

  • Thinking of a new player. Should I give creative another cha

    I went through 4 Creative Zen micro 's. Each one a replacement of the last due to malfunctions. Even the 4th one malfunctions and creative said they would help me with it but never followed up (even after me replying multiple times). So since this on