java i/o... need help reading values from file

M

morc

hey i need to read the values from some log files.

the format is like this :

Time Price
082257 0.0295
090110 0.03
090200 0.03
091503 0.0305
091504 0.0305
091514 0.0305
091522 0.0305
091917 0.0305
092203 0.0305

Does anybody have any suggestion of how id iterate through all these
price values to find the highest and lowest??
I will also be needing to find price values for certain times. but
mainly my focus right now is just to retrieve the high and low. If
anyone has any ideas how to go about his it would be greatly
appreciated if you would post :)

thanks alot
-morc
 
R

Roedy Green

092203 0.0305
Since they are in fixed columns, you could use substring to extract
them, or approximately extract them, then trim. Read the file with a
BufferedReader
http://mindprod.com/jgloss/string.html
see http://mindprod.com/applets/fileio.html

You could use a StringTokenizer trained to consider space as a
discardable separator.
http://mindprod.com/jgloss/stringtokenizer.html

You could use a regex split on space.
http://mindprod.com/jgloss/regex.html

you could use a column-mode text editor to insert a comma down the
middle and then read them as a CSV file.
http://mindprod.com/jgloss/csv.html
 
M

morc

hey thanks for those references. i tried using what visen gave me.
Heres the code:

DataInputStream in = new DataInputStream(new
FileInputStream("C:/marc_repository/USXPdata.txt"));
char ch = in.readChar();
System.out.println(ch);

i began to do that just to test it but for some reason. The only values
i get are "?".
I treid the deprecated readLine and it read the first line showing that
i was connected tot he file.
Does anybody know how come its reading question marks??
and also does anyone know of a way to skip the first line?

Thanks again for the help.
-morc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top