我应该编写一个算法,从给定的单词集中整理出字谜。到目前为止我得到了这个
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());
}
}
}
谁能帮帮我?我在分类部分苦苦挣扎。我不知道如何使用我得到的这段代码并将其转换为字符串并将其排序为字谜。