Solved

Issue with RandomaccessFile ReadLine method.

Posted on 2007-03-26
3
636 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 500 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql import cannot be resolved jsp 3 114
Bot application - advice 3 80
swing controls 2 37
Strange router problem - can't access hotmail.com 14 108
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

737 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