public static void main(String[] args) throws IOException{
		AdaptiveHuffmanTree aTree = new AdaptiveHuffmanTree();
		int count = 0;
		int read = 0;
		String str = "";
		while(StdIn.hasNextChar()){
			char c = StdIn.readChar();
			str = str+c;
			if(aTree.characterInTree(c)){
				char[] chs = (aTree.getCodeWordFor(c).toString() ).toCharArray() ;
				for(char i : chs ){
					BinaryStdOut.write(i =='1');
				}
				aTree.update(c);
				count += chs.length;
				
			}else{
				char[] chs = aTree.getCodeWordForNYT().toString().toCharArray();
				for(char i : chs ){
					BinaryStdOut.write(i =='1');
				}
				aTree.update(c);
				BinaryStdOut.write(c);
				count += chs.length + 8;
			}
			read+=8;
		}
		
		if(count %8 !=0){
			char[] chs = aTree.getCodeWordForNYT().toString().toCharArray();
			for(int i  = 0; i < 8 - (count%8); i++ ){
				BinaryStdOut.write(chs[i%chs.length]=='1');
			}
		}
		BinaryStdOut.flush();
		
		String s = "";
		s += str+"\n";
		s += "bits read = "+read+"\n";
		s += "bits transmitted = "+count+"\n";
		double r = ((double)count/(double) read )*100;
		r = 100 -r;
		r = Math.round(r * 10); 
		r = r/10;
		s += "compression ration = " + r+ "\n\n";
		try(PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("statistics.txt", true)))) {
			out.write(s);
		}catch (IOException e) {
		    //exception handling left as an exercise for the reader
		}
		  
				
		
	}