Re: Java Program that allows you to add a record to a file then another program that can read the fi
"Steven Anderson" <email@example.com> wrote:
>Java Program that allows you to add a record to a file then another program
>that can read the file and you can do a search by name...
>I would attached the files but there are mutable pages if someone knows
>and can possible help me with my Programming 2 Assignment that would be
I'd be happy to help. For the writing/reading to a file, you will use the
classes in the java.io package. For writing, I recommend that you wrap a
BufferedWriter object around an OutputStream object (I suggest a FileWriter
object). For reading I suggest the corresponding BufferedReader and FileReader
classes. The buffered versions allow you to write/read an entire line of
For a given record, you have mutiple lines of text. You can delimit new
records by either a blank line, a line with three dashes, or some other consistent
As for searching, simply read in every 5th line, or every 7th line, or whatever
it takes to get all the names, then search through them using the indexOf()
methods in the String class. It would probably be more efficient, to have
a large loop that grabbed a record's name, compared it to the query, and
then skipped to the next record's name.
That should get you started. Let me know if you have any further questions.
DevX Java Pro