Create the file with an editor.
Type: Posts; User: Norm
Create the file with an editor.
It all depends on what the assignment requires the program to do.
You could create the file that is to be read by using an editor and then have the program read it.
Can you ask your instructor what the assignment is so you will know?
You don't need an OutputStream if you are not writing anything to a file.
Add some println statements to the code to show where it is executing and what the values of the variables are as they are set and changed. Their output will show you some of what the program is...
How did it go when you executed the code? What happened?
In your catch block you should call the Event class's printStackTrace() method to show any exception.
I assume that "asks the user" means you need to display a message and provide a way for the user to enter the filename that can be read into the program. The Scanner class has methods for reading...
It does not cause problems if you put extra statements inside of the try block.
The one thing that can be a problem is the scope of any variables defined inside a try block. They won't be known...
You can also use the Scanner class to read the contents of the file.
There are many sample programs on the forumthat use the Scanner class. Do a Search here.
Also be sure to read the API doc for...
Do you mean the contents of the file
or the name of an existing file?
See the Scanner class for an easy way to read input from a user from the console.