I have a java assignment due for college (I'm doing 2nd year multimedia programming) in a few weeks and I’m really struggling and don’t have a clue what to do.
The following is the first part of the assignment. I have to implement a Java application that demonstrates the use of file input/output and exception handling. my application should allow the user to enter data about some entity that is stored in a data file. My application should be able to read data from a data file, and to store that data in a set of objects.
The following is what I have already. A lot of it is probably wrong, and I don't know what to do next.
BookTest.java
Books.javapackage books; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.PrintWriter; import java.util.Scanner; public class BookTest { public static void main(String[] args) throws FileNotFoundException { File f = new File (input.txt); if (); { FileReader = new FileReader(); } /* BufferedReader = new BufferedReader(); PrintWriter pw = new PrintWriter(File);*/ //Prompts the user for the input and output file names /* Scanner console = new Scanner(System.in); System.out.print("Input file: "); String inputFileName = console.next(); System.out.print("Output file: "); String outputFileName = console.next(); //Prompts the Scanner and PrintWriter objects for reading and writing File inputFile = new File(inputFileName); Scanner in = new Scanner(inputFile); PrintWriter out = new PrintWriter(outputFileName); int lineNumber = 1; */ /* while (in.hasNextLine()); { String line = in.nextLine(); out.println("/* " + lineNumber + " * " + line); } in.close(); out.close(); */ } }
I would really appreciate it if anyone could help me please. Thank you.