This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Searching a file

 
Chris Fetterley
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create a program that will bring in a file, search for a variable entered into a text field and and return the value after it in another text field. I'm assuming that I want to use randomAccessFile to do this? but I keep running into errors with String variables. is there an easy way to do this?
 
Leslie Chaim
Ranch Hand
Posts: 336
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your file have fixed-length records? If not then randomAccessFile is only going to cause you headaches
What kind of file is it; I am not sure what you mean by variable.
Is this some little GUI that you are writing?
 
Chris Fetterley
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes it is a GUI. I'm trying to use one textfield to have the user enter the data and then have that data searched through the file followed by outputting the next five letters in the next field. So should I use a dataInputStream then?
 
Leslie Chaim
Ranch Hand
Posts: 336
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So should I use a dataInputStream then?
It all depends on the structure of your file. I will make an assumption based on:

then have that data searched through the file followed by outputting the next five letters in the next field.

That you file is a text file with the following format:

If indeed this is the format, I'd use a some LineReader (BufferedReader or whatever) then use regular expression as follows:

Does this help?
[ June 20, 2003: Message edited by: Leslie Chaim ]
 
Chris Fetterley
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for the "......." do I want to convert the information entered in my textfield to a string and have it checked that way?

Thanks for the help!!
 
Leslie Chaim
Ranch Hand
Posts: 336
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do I want to convert the information entered in my textfield to a string and have it checked that way?
Not sure I understand your question. Please elaborate and give some examples.
Thanks for the help!!
So, are you a happy camper or not
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic