I have a basic Java file I/O question. I am trying to read/write from/to a text file (obviously) from within a function that is called by main(). Can you do the following within a function:
Scanner inFile = new Scanner(new FileReader("File1.txt"));
PrintWriter outFile = new PrintWriter("File2.txt");
or does this have to be done within main()? If within main(), then how do you get inFile and outFile to work in the function? Do you pass them like a normal parameter?
I tried creating the inFile and outFile objects within a function, but kept getting errors when the program compiled. Thanks...
Jaden403