Solved

java.io.BufferedReader   readLine()  //returns the entire file ?

Posted on 2016-11-22
4
30 Views
Last Modified: 2016-11-28
I am using an implantation of Rhino Java and trying to read a file.

Several examples on-line show looping through the file line by line and appending each until the readLine()  returns null, then you should have the entire file in you string that you were appending.  

The behavior that I am observing is that the readLine() method is executed once and it returns the entire file ?
What is going on ?
I can search the string that it returns and I find the \r\n's in the proper locations ?

var reader = new java.io.FileReader(file);
var bReadr = new java.io.BufferedReader(reader);	
var sb = new java.lang.StringBuilder;

	while ((sLine = bReadr.readLine()) != null)
	{ 
		sb.append(sLine + "\n");
	}

Open in new window

0
Comment
Question by:sidwelle
4 Comments
 
LVL 26

Accepted Solution

by:
dpearson earned 500 total points
Comment Utility
That code looks fine, so it sounds like some issue with the Rhino implementation.

I'd suggest stepping into the "readLine" method inside a debugger to see what it's reading.  The code should be pretty easy to follow as it scans the contents of the file.

Doug
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
What is going on ?
There's <= 1 line in the file?

If you attach the file, we can look
0
 
LVL 16

Expert Comment

by:krakatoa
Comment Utility
Where, in the Java API, do you encounter the type "var" ? I missed that one.
0
 

Author Closing Comment

by:sidwelle
Comment Utility
I think you are right, I keep getting these false errors that take a lot of time to track down.
This time there were two functions w/same name, should have thrown an error on compile.

Thanks
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
IT Company 5 67
network + 7 72
array11 challenge 16 50
maven project error 5 16
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now