Issue with RandomaccessFile ReadLine method.

Posted on 2007-03-26
Medium Priority
Last Modified: 2012-05-05
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))
                                 if (count_names >5)

However the code doesn't seems to be getting into the While loop at all. Any reasons why It might be doing so.
Question by:bjuneja_2000
  • 2
LVL 11

Accepted Solution

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:


Author Comment

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

Expert Comment

ID: 18798235
You're welcome :-)

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

624 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