i've already split the string at the "=" into two arrays, the string array and float array. How do i actually start reading the file from 8th line? i dont want to start reading from the first line. Any help will be appreciated thanks.
Because the lines aren't the same length, there's no way to start reading from the eighth line except for looking through the first part of the file and finding the first seven newlines, then starting to read. The easiest way to do this is probably just to read and discard the first seven lines using BufferedReader.readLine(), but if you insist, you could examine the individual characters, watching for \n's and \r's and counting them until you find where the eighth line starts.
Another option is to normalize the contents of that file, so that it looks like a properties file. Then you simply read the value off the keys without counting them or guessing where they are.
I like that, John. Since all lines are name value pairs I'd probably read them all into a map and then just pull out the keys I needed. If you had to do a few million of them, the overhead of mapping some keys you don't really use might add up, but for reasonable data sets I'd make the code easy to read and maintain first.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Stan James: I like that, John. Since all lines are name value pairs I'd probably read them all into a map and then just pull out the keys I needed. If you had to do a few million of them, the overhead of mapping some keys you don't really use might add up, but for reasonable data sets I'd make the code easy to read and maintain first.
No need to load all the key-values into a map. You can use java.util.Properties and can get particular value by supplying its key.
I'd have to try to be sure ... will a properties file work with those spaces in the key names? If so, it's a better choice to use code that's already there for sure.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi