syedaamiruddin 0 Newbie Poster

plz help me with code

import java.io.*;

public class FreqOrder {

        String[] word=new String[30];
        int chars[];
        public static void main(String... ar){
           FreqOrder fc=new FreqOrder();
             try{ fc.getWords();}catch(IOException e){}

          }  

       public  void getWords() throws IOException{

        FileInputStream fin=new FileInputStream("abc.txt");
        StreamTokenizer st=new StreamTokenizer(fin);
        st.eolIsSignificant(true);
        st.wordChars(33,255);
        st.whitespaceChars(0,32);

        int i=0;
        int nooftoken=0,tokenno=0;

        while(st.nextToken()!=st.TT_EOF)
         {

               switch(st.ttype){
               case StreamTokenizer.TT_WORD:
                  {
                    word[tokenno]=st.sval;
                   tokenno++;nooftoken=tokenno;break;
                  }


               }     
     }  
         frequencymethod(word,nooftoken);
        }

       public void frequencymethod(String[] s,int len){
         String[] counted=new String[len];
         int freqcount=1;
         int[] freqarray=new int[len];

          for(int i=0;i<len;i++){
            freqcount=1;
            for(int j=i+1;j<len;j++){
           if(s[i].equals(s[j]))
             {freqcount++;}
               }
            freqarray[i]=freqcount;
             } 
             freqorder(s,freqarray); 
           }

          public void freqorder(String[] str,int[] fa){
            String temp="";
            String init=str[0];
            for(int i=1;i<fa.length;i++){
              while(init<fa[i]){temp=str[i];str[i]=init;init=temp;}


              System.out.println(str[i]);
            }
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.