Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 26th, 2006, 04:48 AM
Authorized User
 
Join Date: Apr 2006
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error message - class java.io.BufferedInputStream

Could anyone please tell me why am I getting this error message

c.java:15: cannot resolve symbol
symbol : method readLine ()
location: class java.io.BufferedInputStream
while((line = br.readLine()) != null)

Thanks

Reply With Quote
  #2 (permalink)  
Old April 26th, 2006, 06:07 AM
Authorized User
 
Join Date: Mar 2006
Location: , , United Kingdom.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What kind of object is br? Does that object have a readLine() method?

And I think your line of code should read:
while((line==br.readLine())!=null)

because a single = is only used for assigning values AFAIK.

Reply With Quote
  #3 (permalink)  
Old April 26th, 2006, 06:23 AM
Authorized User
 
Join Date: Apr 2006
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is my code
===============

public void insertline() throws java.io.IOException
{
           File inp=new File("output.txt");
           FileInputStream fr = new FileInputStream(inp);
           BufferedInputStream br=new BufferedInputStream(fr);
           boolean flag=true;
    while((line = br.readLine()) != null)
           {
               int present=line.indexOf(STRING_TO_REPLACE);
               if(present==0)
               {
                   flag=false;
               }
           }
           br.close();
           if(flag)
           {
               lineInsertion("output.txt");
           }
}


A single = is fine, because I am assigning values
while((line==br.readLine())!=null)


Thanks

Reply With Quote
  #4 (permalink)  
Old April 28th, 2006, 06:28 AM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

BufferedInputStream doesn't have readLine()

Replace the BufferedInputStream with a BufferedReader:
Code:
BufferedReader br = new BufferedReader(new InputStreamReader(fr));
Reply With Quote
  #5 (permalink)  
Old May 2nd, 2006, 12:08 AM
Authorized User
 
Join Date: Apr 2006
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot, that really helped.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to delete file System.IO.Delete error maricar C# 13 March 14th, 2014 06:50 AM
Java Best Practices Class gxp Spring 0 August 21st, 2008 06:02 PM
Java IO error bb1234_00 Java Basics 2 March 26th, 2007 07:25 AM
Using Java class from C# gettipu J2EE 0 February 7th, 2005 05:57 PM
java.io.FilePermission while accessing JSP melida JSP Basics 0 October 9th, 2003 05:32 AM



All times are GMT -4. The time now is 04:37 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.