I'm trying to reduce the number of for loops in this method, but I'm not sure how to do that while still keeping the logic in tact and not moving to another method. I want to do this for the sake of reducing the McCabe Cycolmatic Complexity, which increases with each loop by 1. So I'd like to reduce the method by 1.
private void method(int page)
{
for (int i = 0; i < LINES_PER_PAGE; i++)
{
nextLine[i] = null;
}
try
{
Scanner temp = new Scanner(fileToPrint);
for (int i = 0; i < page - 1; i++)
{
skipAPage(temp);
}
for (int i = 0; (i < LINES_PER_PAGE) && (temp.hasNext()); i++)
{
nextLine[i] = expandTabs(temp.nextLine());
}
} catch (FileNotFoundException e)
{
e.printStackTrace();
}
}