?
Solved

Issue with RandomaccessFile ReadLine method.

Posted on 2007-03-26
3
Medium Priority
?
650 Views
Last Modified: 2012-05-05
Hi,
I implemented the following while loop  after doing a write to a file :
raf_name=new RandomAccessFile("c:\\movie_name29.txt","rw");
raf_name.writeBytes(ss_name + "\r\n");
 while((text1 = raf_name.readLine()) != null)
                        {
                                if (text1.equalsIgnoreCase(searchString_name))
                             {
                                 count_names=count_names+1;
                                 if (count_names >5)
                                    {
                                       
                                       break;
                                       
                                    }
                                 }
                             }


However the code doesn't seems to be getting into the While loop at all. Any reasons why It might be doing so.
Regards
0
Comment
Question by:bjuneja_2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
elfe69 earned 2000 total points
ID: 18798106
It is because you are at the end of the file after the call to writeBytes().

add the following between writeBytes() and the while loop and you will return to the beginning of your file:

raf_name.seek(0);
0
 

Author Comment

by:bjuneja_2000
ID: 18798232
Thanx a zillion for pointing that out.. Thats the difference between a novice and expert :- ) ...
0
 
LVL 11

Expert Comment

by:elfe69
ID: 18798235
You're welcome :-)
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month12 days, 5 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question