Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

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

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
sidwelle
Asked:
sidwelle
1 Solution
 
dpearsonCommented:
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
 
CEHJCommented:
What is going on ?
There's <= 1 line in the file?

If you attach the file, we can look
0
 
krakatoaCommented:
Where, in the Java API, do you encounter the type "var" ? I missed that one.
0
 
sidwelleAuthor Commented:
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
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now