I'm working on a task where the results of a method will print into an existing text file. How do I get this method to print into the file, instead of the main when getDivisors() is called in the main? In the main method, I also ask the user for input of a name and it will create a .txt file with numbers inside the file.
public static void getDivisors(double n)
{
for (int i=1;i<=n;i++)
if (n%i==0)
System.out.println(i+" ");
System.out.println("The divisors for " + n + " are" + " listed above");
System.out.println(" ");
}