Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2006, 04:48 AM
Authorized User
 
Join Date: Apr 2006
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

 
Old April 26th, 2006, 06:07 AM
Authorized User
 
Join Date: Mar 2006
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.

 
Old April 26th, 2006, 06:23 AM
Authorized User
 
Join Date: Apr 2006
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

 
Old April 28th, 2006, 06:28 AM
Registered User
 
Join Date: Apr 2006
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));
 
Old May 2nd, 2006, 12:08 AM
Authorized User
 
Join Date: Apr 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot, that really helped.






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 06:57 PM
java.io.FilePermission while accessing JSP melida JSP Basics 0 October 9th, 2003 05:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.