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
Solved

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

Posted on 2016-11-22
4
94 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 27

Accepted Solution

by:
dpearson earned 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet doXXX methods 3 62
Error in @AspectJ Based AOP with Spring 2 18
login form jsp example 2 37
swing controls 2 16
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

856 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