public static void main(String[] args){
      ArrayList<String> valArr = new ArrayList<String>();
      ArrayList<node> nodeList = new ArrayList<node>();
      
      try{
         String input;

         System.out.println("----------HUFFMAN CODING----------");
         System.out.println("Please enter the file name to be read...");
         
         //Reads in input
         Scanner scan = new Scanner(System.in);
         input = scan.next();
         File file = new File(input);
         InputStream inStream = new FileInputStream(file);
         Reader reader = new InputStreamReader(inStream);
         String[] cHolder = new String[128];
         //Fills array with characters
         for(int i=0; i<128;i++)
            cHolder[i] = Character.toString((char)i);

         int[] frequencyArr = new int[128];
         Arrays.fill(frequencyArr,0);
         int holder;

         while((holder = reader.read()) != -1){//updates frequency of characters
            int index = (int)holder;
            frequencyArr[index]++;
         }
         
         for(int i = 0;i<128;i++){//Adds value to proper array lists
            if(frequencyArr[i] >0){
               valArr.add(cHolder[i]);
               freqArr.add(frequencyArr[i]);
            }
         }
         
         int n = freqArr.size();
         
         for(int i = 0; i<n;i++){
            node h = new node();
            h.val = valArr.get(i);
            h.frequency = freqArr.get(i);
            nodeList.add(h);
         }
         
         reader.close();
         scan.close();
         
         ArrayList<node> tList = (ArrayList<node>)nodeList.clone();
         node t = Huffman(tList);
         printCodes(t, new StringBuffer());
         //new input stream
         inStream = new FileInputStream(file);
         reader = new InputStreamReader(inStream);
         File f = new File("HuffmanOutput.txt");//Begin writing to file
         FileWriter fWrite = new FileWriter(f);
         BufferedWriter bWrite = new BufferedWriter(fWrite);
         
         int holderr;
         int finishedSize = 0;
         int originalSize = 0;
         
         while((holderr = reader.read())!= -1){
            for(int i=0; i<replaceArr.size(); i++){
               if((char) holderr==((replaceArr.get(i)).original).charAt(0)){
                  bWrite.write((replaceArr.get(i)).replace);
                  finishedSize = finishedSize + ((replaceArr.get(i)).replace).length();
                  originalSize++;
               }
            }
         }
         bWrite.close();
         reader.close();
         System.out.println("Length of input file is: "+originalSize);
         System.out.println("After implementing Huffman, the length is now: "+finishedSize);
      }

      catch(IOException e){
         System.out.println("ERROR: IOEXCEPTION:  "+ e );
      }
   }