Is this just a console program? If it is, you can either take input from the command line or from the console during the program execution. Example:
From Command Line:
Code:
public static void main(String[] argv) {
//argv[0] = first command line parameter (different from C++ style)
ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream(argv[0]));
//.. other code here...
}
Then you would invoke this with something like:
java ProgramName "Name of file.dat"
Alternatively, you can prompt the user for input with something like.
Code:
public static void main(String[] argv) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("File Name: ");
String fileName = in.readLine();
ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream(filenName));
// Other code here
}
For this code, after you run the class, the program will pause and wait for you to enter input on the console.
Hope this helps.
Bookmarks