I have a file and inside it has some tables and my question is how can I create a new file but in this file it includes both tables and additional information. I tried in terminal but I could not find it, help me please...
Asked
Active
Viewed 76 times
0
-
This isn't even close to enough information to begin to help you. Please elaborate. how can a file have tables? is it HTML? CSV? something else? Define exactly what you have and what you're trying to do – Brian Pipa May 25 '17 at 12:42
-
in java I made a code that shows the table of student id and quizzes in "scores.txt" but in the next text called "finalReport.txt" I want to add averages – Ekin May 25 '17 at 13:02
1 Answers
0
How do you want to check when to create a new file, when is the next text called ?
How about to use JFileChooser, just choose or create a new file ?
Maybe something like this:
private void createNewFile() {
File newFile;
File nf = null;
String nt = "someName";
if((newFile = new File(DirectoryPath.toString())).exists()) { //it must be a directorypath to create a new file in it.
nf = new File(DirectoryPath, "withAverage" + nt + ".txt"); //create a new file
nf.createNewFile();
} averageFile = nf;
}
private void fileWriterInput() {
FileWriter fw = new FileWriter(averageFile);
try (BufferedWriter bw = new BufferedWriter(fw)) {
bw.newLine();
bw.append(inputString);
bw.append("----------------------------------");
bw.flush();
}
}

loadP
- 404
- 1
- 4
- 15
-
I mean I have some code that calculates averages.... and I create a file like a.writeData("scores.txt") but in the new file I want to create, "finalReport.txt", this file shows me the averages and scores.txt just should show me the quizzes – Ekin May 25 '17 at 17:07
-
Files may have content/data, but each file should have it's own existence. Or you mean you want to merge it or to copy content from one file to the other file ? Maybe you mean to start a new filewriter stream to create a new file. – loadP May 25 '17 at 19:28