@OP
http://tams-www.informatik.uni-hamburg.de/applets/hades/webdemos/10-gates/50-hamming/hamming.html
http://www.frontiernet.net/~prof_tcarr/Hamming/
http://math.arizona.edu/~ura/043/Patterson.Genevieve/Final/FinalReportSummer2004/node14.html
http://www.cs.utsa.edu/~wagner/laws/hamming.html
http://galeb.etf.bg.ac.yu/~prvul/Comm/Code.java
here are few links which specifies Hamming Code Simulation / Implementation Using JAVA...
Hop this might be of some help...:)
REGARDS,
RaHuL
try to first learn how hammingcode works. Rahul provided some useful Url. Try to learn some from my code and see if you can write your own hammingcode. if you need help or if you get stuck please post back.
public class printBits2{
public static void main( String args[] ){
printBits2 pb = new printBits2( args[ 0 ] );
}
public printBits2( String message ){
//System.out.print( message + "\n\n" );
char chA[] = new char[ message.length() ];
chA = message.toCharArray();
System.out.print( chA[ 0 ] + " -> is your input char\n" );
printCharBits( chA[ 0 ] );
System.out.print( " -> is what computer sees\n\n" );
toHamming( chA[ 0 ] );
}
private void toHamming( char c ){
char displayMask = 1 << 0;
char n[]; n = new char[ 4 ]; n[ 0 ] = 91; n[ 1 ] = 109; n[ 2 ] = 7; n[ 3 ] = 7;
int j = 0;
boolean b = true;
char HC = 0 << 15;
for( int i = 16; i > 5; i-- ){
if( 16 % ( 17 - i ) == 0 ){
//insert the appropriate parity bits
n[ j ] = (char) ( c & n[ j ] );
for( int k = 0; k < 7; k++ ){
if( (int) ( n[ j ] & displayMask ) == 1 ){ b = !b; }
n[ j ] >>=1;
}
if( ! b ){
int helpMask = 1 << (int) ( Math.pow( 2, j ) - 1 );
HC = (char) ( helpMask | (int) HC );
}
j++;
b = true;
}
else{
if( ( c & displayMask ) == displayMask ){
int helpMask = 1 << ( 16 - i );
HC = (char) ( helpMask | (int) HC );
}
c >>=1;
}
}
printCharBits( HC ); System.out.print( " -> hamming code computer sees\n\n" );
}
private void printCharBits( char c ){
char displayMask = 1 << 15;
for ( int bit = 1; bit < 17; bit++ ){
if( ( c & displayMask ) == 0 ){
System.out.print( "0" );
if( bit % 8 == 0 ){ System.out.print( " " ); }
}
else{
System.out.print( "1" );
if( bit % 8 == 0 ){ System.out.print( " " ); }
}
c <<= 1;
}
}
}