Joined: Wed Mar 28, 2007 1:17 pm Posts: 118 Location: Cairo-Egypt Has thanked: 0 time Have thanks: 5 time
This is java J2SE program for Huffman com-decom algorithm that let the user to browse for the file that need to compress or decompress and then make the required operation by huffman coding.
1. Run the program . 2. If you have a text and you want to compress click on Compress button and then select text file. 3. The compressed file (com.txt) and dictionary (dic.txt) will be created. 3. if you want to decompress the compressed file click on Decompress button and select com.txt file. 4. The decompressed file (decom.txt) will be created.
Note-->If you want to decompress put the dict.txt file with the com.txt file in the same location.
For this message the author tetosoft has received gratitude : evacide
} public void sort_my_data(myDataList myLinklist) { Collections.sort(myLinklist,my_comparator); } /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here
new Main(); } public void evaluate_code() { myDataList linklist=(myDataList) mylist.clone(); myDataList temp; int size=linklist.size(); // System.out.println(size);
private BufferedReader ReadHand2; private JFileChooser c = new JFileChooser(); private BufferedReader ReadHand1; private String path;
public void paint(Graphics g) { super.paint(g); Graphics2D g2d=(Graphics2D )g;
g2d.setBackground(Color.BLACK); g2d.setColor(Color.RED); g2d.drawString("www.codemiles.com team works",50,100);
} } class myDataList extends LinkedList {
public Object clone() { myDataList cp=new myDataList(); data mydata;
for(int i=0;i<size();i++) { mydata=(data)get(i); cp.add(new data(mydata.getChar(),mydata.get_probability(),mydata.isFlag())); } return cp; } }/* * * Please Visit us at www.codemiles.com * * This Program was Developed by www.codemiles.com forums Team * * Please Don't Remove This Comment * */
Code:
/* * * Please Visit us at www.codemiles.com * * This Program was Developed by www.codemiles.com forums Team * * Please Don't Remove This Comment * */
package huffman_compersion;
import java.util.Comparator;
/** * * @author mohamed */ public class data_Comparator implements Comparator {
/** Creates a new instance of data_Comparator */ public data_Comparator() { }
public int compare(Object o1, Object o2) { int prob_diff=((data)o2).get_probability()-((data)o1).get_probability();
} /* * * Please Visit us at www.codemiles.com * * This Program was Developed by www.codemiles.com forums Team * * Please Don't Remove This Comment * */
Code:
/* * * Please Visit us at www.codemiles.com * * This Program was Developed by www.codemiles.com forums Team * * Please Don't Remove This Comment * */