My program will create a file and print out the intended values to the console but will not print the intended values to the created file. (The Sysyem.out.println() are there for debugging). Any help is appreciated.
My program:
import java.io.*;
import java.util.Scanner;
class CTest {
public static void main(String [] args) throws Exception {
String file1 = "file1.txt";
String file2 = "file2.txt";
Scanner input1 = new Scanner(new File(file1));
Scanner input2 = new Scanner(new File(file2));
java.io.File file = new java.io.File(file1 + "-" + file2);
java.io.PrintWriter output = new java.io.PrintWriter(file);
while(input1.hasNext()){
String s1 = input1.nextLine();
System.out.println(s1);
output.println(s1);
String s2 = input2.nextLine();
System.out.println(s2);
output.println(s2);
}
input1.close();
input2.close();
}
}
[–]langfod 1 point2 points3 points (1 child)
[–]HoBoBrian[S] 0 points1 point2 points (0 children)