Thu Apr 05, 2012 12:36 pm
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());
}
}
}
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
Powered by phpBB © phpBB Group.