Total members 11894 |It is currently Sat Nov 23, 2024 10:22 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Hi, I'm supposed to write an algorithm sorting out anagrams from the given list. So far I got the list read in eclipse, but struggling with the sorting part. Can anyone help me out? This is my code so far

Code:
package Tutorial5;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;


public class Anagrams {

   /**
    * @param args
    */
   public static void main(String[] args) {
      
      try{
         FileInputStream fis = new FileInputStream("src/Tutorial5/words"); //locate and open the txt.file
         
         DataInputStream dis = new DataInputStream(fis); //get the words from the txt.file
         
         BufferedReader br = new BufferedReader(new InputStreamReader(dis));
         
         String SLine;
         
         
         while ((SLine = br.readLine()) != null) //read the txt.file line by line
         {
            System.out.println(SLine); //print out the words
      }
      
      dis.close(); //close the DataInputStream
      
   }
      catch (Exception e) //see if there is any exception to catch
      {
         System.err.println("Error: " + e.getMessage());
      }
      
}
}


Related to
java/java-anagram-t5455.html




Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 




cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com