Originally Posted by Norm
|
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.