I have two files of huge data contains string and integers
and i want to read from it and use it to count characters of the string for example name ending with letter "A" containing "oo" or having letter "A" as seconf letter.

i need some methods from the String class or i can use StringTokenizer Class.

please help me or give a hint

Thanks :)

I have two files of huge data contains string and integers
and i want to read from it and use it to count characters of the string for example name ending with letter "A" containing "oo" or having letter "A" as seconf letter.

i need some methods from the String class or i can use StringTokenizer Class.

please help me or give a hint

Thanks :)

Hi

It much depends on how your file looks.

Are the word separated by empty space, some token or an integer then you can use StringTokenizer to separate the words and for every word separated you can make the check you want to do, eg. is second letter in this word an 'A' and so on.

If you only want to count all 'a' in your string you can make a loop that runs as long as file is not empty and for every 'a' found a counter increases. Be ware if you have empty space in your file between words then you might have to add a special token last in the file that tells the loop that the file is empty.

I would also suggest that you use the latest API:
http://java.sun.com/javase/6/docs/api/

Hope this gave you some help :)

Hi

It much depends on how your file looks.

Are the word separated by empty space, some token or an integer then you can use StringTokenizer to separate the words and for every word separated you can make the check you want to do, eg. is second letter in this word an 'A' and so on.

If you only want to count all 'a' in your string you can make a loop that runs as long as file is not empty and for every 'a' found a counter increases. Be ware if you have empty space in your file between words then you might have to add a special token last in the file that tells the loop that the file is empty.

I would also suggest that you use the latest API:
http://java.sun.com/javase/6/docs/api/

Hope this gave you some help :)

Thank you so much this really helped :)

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.