I am trying to write the test result in csv file by using BufferedWriter. The test duration for WAF5-H is 2 seconds. and WAF6-L is 5 seconds. My output file is:
Thu Feb 18 14:01:07 CET 2016;0;WAF5-H;
WAF5-H;
Thu Feb 18 14:01:08 CET 2016;0;WAF5-H;
WAF5-H;
Thu Feb 18 14:01:09 CET 2016;0;WAF5-H;
WAF5-H;
I expected:
Thu Feb 18 14:01:07 CET 2016;0;WAF5-H;
Thu Feb 18 14:01:08 CET 2016;1;WAF5-H;
Thu Feb 18 14:01:08 CET 2016;2;WAF5-H;
until test end then the next job will begin.
for (int i = 0; i < convertedDifference; i++) {
for (Job currentJob : NEHCalculator.addNewJobInitializeList()) {
int testDevice = (DeviceGroups.DeviceAList.size() + DeviceGroups.DeviceBList.size()
+ DeviceGroups.DeviceCList.size() + DeviceGroups.DeviceDList.size());
int times = (int) ((convertedDifference / currentJob.getInterval()) * testDevice);
for (int t = 0; t < times; t++) {
// until end of the test date.
cal.add(Calendar.SECOND, 1);
beginDate.getTime();
// write the test date
bufferedWriter.write(String.valueOf(cal.getTime()));
bufferedWriter.write(';');
// write the test total second begin with 0.
bufferedWriter.write(String.valueOf(i));
bufferedWriter.write(';');
double j = 0;
for (j = 0; j < currentJob.getNeededTestTime(); j++) {
bufferedWriter.write(currentJob.getJobname());
bufferedWriter.write(';');
bufferedWriter.newLine();
}
}
i++;
}
}
bufferedWriter.close();// Always close files.
The first for loop explain do the test until test ending time. ( actual output violated this because it write down 0 2 times so it will continue until 13442.. . Normally I expected to see 3600 lines in my csv file.
The second for each loop get the selected job list.
Third for loop explains how many time testing will be occured. ( I entered 1 hour testing time and testing time will make every 15 minutes and WAF 5H tests 4 devices. So 4*4*2 = 32 times I would like to see WAF5-H on the csv file.
Last for loop explains the needed time testing for each required machine. ( For WAF 5-H 2 seconds.)
Could someone please help me
bufferedWriter.write(String.valueOf(i));will write 0 as many times as the inner for loop runs (maybe you wanted to puttinstead ofithere). And you have an even inner loop (forusingjthat writes the job name and prints a new line. I think the result you get is pretty much the correct one for your code.