Firstly i would like to say Hello to everyOne.Am a Computer Science Student and Am new in Java Programming.My first program is to write a program that will read a file and display the sum of all values.

....wanted to use BufferedReader to read the file and store the values i get in the buffer.....

BufferedReader someBuffer =new BufferedReader(new FileReader("MyFile.txt");

This implies that am gonna read the File and store my values in someBuffer.....

The problem is how am gonna manipulate my buffer and display the sum of my values.

Lets say the file contains this data
101 102 103
213 214 215
312 324 356
thanks in advance for the help/

Recommended Answers

All 3 Replies

Great problem! :D but I don't see any effort here. Where is your code?

Hi Shaqnolysis,

I think you have a good place to start with the BufferedReader class, but it might pay to have a good read of the Java API for that class. It's probably a good idea to bookmark this link as I can assure you it will be very valuable throughout your Java programming career!

I hope I have given you a good place to start, but let us all know if you need any more help.

Cheers
darkagn

This implies that am gonna read the File and store my values in someBuffer.....

Well, that is not what it does. It simply buffers the read stream so that every read function does not have to actually be directly reflected on the disk. It saves a little time (in your case, with such a small file and only a few reads necessary, a miniscule amount, but that is the principle).

You still need to actually "read" the data, using readLine, split the line using split() storing each value as an int (probably). Read the API for BufferedReader, String, and Integer, as well as the IO Tutorials. http://java.sun.com/docs/books/tutorial/essential/io/index.html

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.