All pastes #2062016 Raw Edit

Anonymous

public text v1 · immutable
#2062016 ·published 2011-05-17 06:17 UTC
rendered paste body
public void ecrireFichierCompresse() throws FileNotFoundException{
	//1-lire le fichier caractere par caractere pour trouver son code binaire equivalent
		try{
	    	  FileInputStream fichierTxt = new FileInputStream("C:/Users/Fadia/test2.txt");
	          int c = 0;
	          //BinaryStdOut.BinaryInstanciate(); 
	       try {
	  			out = new BufferedOutputStream(new FileOutputStream("C:/Users/Fadia/test2.dat"));
	  		} 
	      	catch (FileNotFoundException e) {
	  			// TODO Auto-generated catch block
	  			e.printStackTrace();
	  		}
	          
	          arbreBinaire.buildTablecode();
	          
	          // On insere l'entete sur la premiere ligne
	          write(arbreBinaire.getEntete()+"\n");
	          
	          while ( fichierTxt.available() > 0 ) 
	          {
	          char current = (char) fichierTxt.read();
	          String code = arbreBinaire.getCodeForCaractere(current);
	          for (int j = 0; j < code.length(); j++) {
	                if (code.charAt(j) == '0') {
	                    write(false);
	                }
	                else if (code.charAt(j) == '1') {
	                    write(true);
	                }
	                else throw new RuntimeException("Illegal state");
	            }
	          }
	          flush();