Hey guys I'm using dictionary.txt file and need to display first word from each line so I can then randomly pick 100 of them and find word definitions for it.
I'm having problem with displaying first words, for some reaso I can only display words starting with 'S'.
Here is what I have so far:
I'm having problem with displaying first words, for some reaso I can only display words starting with 'S'.
Here is what I have so far:
Code:
public static void main(String args[])
{
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("dictionary.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
String[] delims = strLine.split(" ");
String first = delims[0];
for(int i = 0; i < delims.length-1; i++ )
{
System.out.println(delims[i]);
}
}
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
Comment