'end of file' in JAVA


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: 'end of file' in JAVA

  1. #1
    Join Date
    Mar 2003
    Posts
    3

    'end of file' in JAVA

    Hi!

    How do we check for the 'end of file' in JAVA?

    When we open a file and wish to read it till the end, we need to check for the end of file, right? [in C (while(!feof()))] How is that done in JAVA?

    thanks!

    -Trixie

  2. #2
    Join Date
    Mar 2003
    Posts
    84
    well one way to check for it is just to read the file line by line by line and check for null.


    for instance if you are loading a line of your file into a string called testThis,

    just use the loop

    while(testThis != null)
    {
    do what you want to do here.;
    }
    someFile.close();

    I usually just do it the same as in C and write


    while(!tesThis.atEOF())
    {
    do stuff.
    }
    someFile.close()

    and then write the method atEOF()

    public boolean atEOF()
    {
    if(this.getData = null)
    return true
    else
    return false
    }
    I'm surprised more of you people don't get hit by cars.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center