?
Solved

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

Posted on 2016-11-22
4
Medium Priority
?
117 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
[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
4 Comments
 
LVL 28

Accepted Solution

by:
dpearson earned 2000 total points
ID: 41898207
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
ID: 41898218
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
ID: 41898349
Where, in the Java API, do you encounter the type "var" ? I missed that one.
0
 

Author Closing Comment

by:sidwelle
ID: 41904774
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 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