This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "CRC Computation using algorithm" Watch "CRC Computation using algorithm" New topic

CRC Computation using algorithm

kirrz nar

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

Joined: Sep 28, 2004
Posts: 20057

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.


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: 14961

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 Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Have you checked out Aspose?
subject: CRC Computation using algorithm
It's not a secret anymore!