Search:

Type: Posts; User: Norm

Search: Search took 0.09 seconds.

  1. Thread: File I/O

    by Norm
    Replies
    20
    Views
    2,408

    Re: File I/O

    Create the file with an editor.
  2. Thread: File I/O

    by Norm
    Replies
    20
    Views
    2,408

    Re: File I/O

    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.
  3. Thread: File I/O

    by Norm
    Replies
    20
    Views
    2,408

    Re: File I/O

    Can you ask your instructor what the assignment is so you will know?
  4. Thread: File I/O

    by Norm
    Replies
    20
    Views
    2,408

    Re: File I/O

    You don't need an OutputStream if you are not writing anything to a file.
  5. Thread: File I/O

    by Norm
    Replies
    20
    Views
    2,408

    Re: File I/O

    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...
  6. Thread: File I/O

    by Norm
    Replies
    20
    Views
    2,408

    Re: File I/O

    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.
  7. Thread: File I/O

    by Norm
    Replies
    20
    Views
    2,408

    Re: File I/O

    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...
  8. Thread: File I/O

    by Norm
    Replies
    20
    Views
    2,408

    Re: File I/O

    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...
  9. Thread: File I/O

    by Norm
    Replies
    20
    Views
    2,408

    Re: File I/O

    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...
  10. Thread: File I/O

    by Norm
    Replies
    20
    Views
    2,408

    Re: File I/O

    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.
Results 1 to 10 of 10