Hi there, I am currently doing a bioinformatics project on dynamic programming.
I need to read a text file, and extract the information in it and use the information in it for my dynamic programming java codes(both java codes must be together). May I know how to extract the information? I think I need to read the file and extract it by rows and columns.

Hi there, I am currently doing a bioinformatics project on dynamic programming.
I need to read a text file, and extract the information in it and use the information in it for my dynamic programming java codes(both java codes must be together). May I know how to extract the information? I think I need to read the file and extract it by rows and columns.

It's important to know the way you want to extract data from file which depends on processing strategy.

You can read file by each byte or read file by line/sized piece using buffered reading.

See on: InputStream, InputStreamReader, BufferedReader and choose most prefereablefor your case.

I am not sure if i get your meaning but is your data like a MYSQL format

If yes extract the rows by reading single lines in a buffer
For the columns use the string split function

Richard

Hi thanks for your reply. String split function? So is it like string tokenization?

May I know how to read and extract by columns and rows?

There is no specific way to extract columns(that i know of), you can use the "Substring" function if all the columns are evenly spaced, or you should try and detect where the next word after the previous starts and get colums that way, there are a lot of ways to do this.

As for reading lines see what Nikelin

See on: InputStream, InputStreamReader, BufferedReader and choose most prefereablefor your case.

posted and use those methods in a loop or/until EOF is reached. this is the easy part.

Regards Krefie

I am not sure if i get your meaning but is your data like a MYSQL format

If yes extract the rows by reading single lines in a buffer
For the columns use the string split function

Richard

Hi Richard, thanks for your reply.
I don't really get it when you said reading single lines in a buffer? What does that mean? And the string split function is it using string tokenizer?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.