Click to See Complete Forum and Search --> : Using an unknown file as input


srananmeitie
11-14-2003, 12:05 AM
Hi,

I am writing a Concordance program that will read from a file (the file name is not known), and print each word with the number of times it occurs and the line number(s).

My problem is with reading the file as input. I know how to read a file when the filename is known, and using keyboard input, but how do I proceed if the filename is not known? (The file is a text file)

I also am a bit confused with FileInputReader and InputStreamReader.

Can someone help me please?

Thanks!

Khalid Ali
11-14-2003, 06:29 AM
unless you have some means to disnguish a file from another ,it will be virtually impossible to know what to do.

What you can do is read the contents of the current directory and then see which files has a *.txt extension and then go from there.

Read the API for InputReaders or StreamReaders