This content has been marked as final. Show 3 replies
Using BufferedReader you can read a file line by line
each line returns String object, using indexOf function you can identified the row which contains the input string (string15).
Using indexOf function you can get the project name (get the position of ":" character)
and using lastIndexOf function (get the position of ",") you can read the date value
so using BufferedReader and String's function like indexOf, lastIndexOf and substring your requirement can be possible.
800512 wrote:In addition to Pandiya's advice, if the string is always in exactly the above format
I need to create a file with some data that has been inserted manually.
In this file, for example, there are:
ProjectName1: string1, string7… string10, date1
1. ProjectName always starts the line and ends with a ':'.
2. The rest of the strings on the line are separated by ", " and will never contain ", "
you might also want to have a look at String.split().
You didn't say how large a typical file is. If the number of lines is very large (100,000 +, for example), you should re-think whether a file is the best way to store & retrieve the data. For large amounts of data (or where searches are done frequently), a database might be a better solution.
But again, you didn't give much info on the problem, so only you can decide whether a file is the best way to go.