Members, please help me understand these question. I have looked over other people code relating to files that are related to my actual studies in class. My teacher hasn't worked on a lot of file problems so I want to gain some understanding on it.
First question:
1.) I have this class with variables declaredimport java.io.*; public class FileDisplay { private String filename; FileWriter outputfile; File Inputfile;
I'm aware that having a private variable would not allow that variable to be accessed outside the code. Vice versa, public variabl would do that. The FileWriter and the File Inputfile is something I don't understand, especially have them in classes. What is the purpose of them?
2.)I have made this code here that opens the output and input file. If I make another method, how would I display the text onto that same file. Hard to clarify for me, but in each method do I just keep creatingpublic class FileDisplay { private String filename; FileWriter outputfile; File Inputfile; //Create a constructor public FileDisplay(String Name_file) throws IOException { filename=Name_file; //Open the output file new FileWriter(filename); //Open the input file new File("Results.txt"); } }FileWriter outputfile=new Filewriter(filename)