View Single Post
  #3 (permalink)  
Old 08-02-2008, 09:58 PM
matt_well's Avatar
matt_well matt_well is offline
Member
 
Join Date: Jul 2008
Posts: 59
Rep Power: 0
matt_well is on a distinguished road
Default
Originally Posted by Norm View Post
Are those filenames? Are you saying that you want to read from one file starting at line 1 and from the other file from line 2?
Since most files are sequential, you must read and skip the records that you do not want to process.

Does that mean to sum all the elements of something?

Yes you can have a for loop that starts the index at any value you want: for(int i=77; i < total; i++)
It read only from one file "Values.txt".

Code:
        for(int i = 0; i < maxSize; i++)
        {
            String data1 = getNextValue(process1, i);
            String data2 = getNextValue(process2, i);

            double sampleData1 = parseValue(data1);
            double sampleData2 = parseValue(data2);

            double total = (sampleData1 + sampleData2);
            pw.printf("%1.4f%n",
                       total);
        }
        pw.close();
        System.out.print( "Total.txt now at C drive");
    }
The code I created have only one for loop.
I mean that how to seperate into two for loop as I want sampleData1 starts to read from 1 and sampleData2 starts to read from 2.
Yes, sum them each row by row.
Reply With Quote