Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: finding the end of ram

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default finding the end of ram

    for(int i=0; i<76; i++) {
                test1 = raf.readLine();
                test2 = raf.readLine();
                test3 = raf.readLine();
                test4 = raf.readLine();
                test5 = raf.readLine();
                test6 = raf.readLine();
                testDouble = raf.readDouble();
     
                Node tempNode = new Node(test1, test2, test3, test4, test5, test6, testDouble);
                Global.GlobalLinkedList.addnode(tempNode);
            }
     
            raf.close();

    i need it so that instead of doing this 76 times it does it until it reaches the end of the of the cat.dat file (very dr.seuss name huh?)


  2. #2
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,225
    Thanks
    176
    Thanked 817 Times in 760 Posts
    Blog Entries
    5

    Default Re: finding the end of ram

    Read the API for the readLine method - given you don't post the code fully I can only guess what raf is (RandomAccessFile?), but typically this method returns null when the end of file is reached. So just check the line returned from readLine - if its null you've reached the end of the file

Similar Threads

  1. finding unescaped XML characters
    By diptee in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 18th, 2010, 03:51 AM
  2. finding pi
    By gonfreecks in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: November 2nd, 2010, 05:15 PM
  3. Finding the Average
    By KiwiFlan in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 16th, 2010, 07:58 PM
  4. [SOLVED] Finding acm package
    By javapenguin in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 12th, 2010, 11:50 AM
  5. Replies: 13
    Last Post: May 6th, 2009, 09:27 AM