my dog learned polymorphism*
The moose likes I/O and Streams and the fly likes CRC Computation using algorithm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "CRC Computation using algorithm" Watch "CRC Computation using algorithm" New topic
Author

CRC Computation using algorithm

kirrz nar
Greenhorn

Joined: Jun 01, 2006
Posts: 1
I've got a file titled input.txt. The first line of the file has a divisor and the second line has the message. I have to write a single Java class that accepts a single command line argument of an integer - and when it is 0 it has to compute the CRC code implementing the CRC algorithm.
Once the checksum computation is completed, the output should be the message with the CRC code.

I know how this works on paper, I just can't seem to put it into Java! What is the algorithm? What is checksum? Help!!!
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19073
    
  40

I know how this works on paper, I just can't seem to put it into Java! What is the algorithm? What is checksum? Help!!!


You are trying to do too much, do something small that is part of the program. For example...

How about writing a method that just opens the file, and reads the input into some location?

How about writing a method that does one iteration of the CRC? How about building on that method, and write a method that feed a whole array of characters into it?

Once you have these pieces, then the overall program is just putting these two pieces together, with some printing code.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14435
    
  23

You know how it works on paper... but it sounds like you don't know what CRC is and how it works. Do a Google search, I'm sure you can find info on the CRC algorithm. I think there are different variants of the algorithm, so you might have to find out exactly which variant you need.

Or, have a look at the API documentation of class java.util.zip.CRC32.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CRC Computation using algorithm