DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3

Thread: BufferedReader

Hybrid View

  1. #1
    Lindsey Guest

    BufferedReader


    Ok. Here is my code. I need to know why i keep getting the same error message.
    The error message is also posted.
    import java.io.*;
    public class more{
    public static void main(String [] args){
    BufferedReader a = new BufferedReader (new
    InputStreamReader (System.a));
    String oneline;
    int countline;
    int countcol;
    countcol = 0;
    try{

    while ((oneline = a.readline() ) != null){
    oneline = a.readLine();
    System.out.println(oneline);
    if (countcol >= 80){
    System.out.println(" ");
    countline =+ 1;
    if (countline == 20){
    break;
    }
    }
    }
    }
    catch( Exception e )
    { System.out.println(e);}
    }
    }



    Error...

    more.java:6: No variable a defined in class java.lang.System.
    InputStreamReader (System.a));
    ^
    more.java:13: Method readline() not found in class java.io.BufferedReader.
    while ((oneline = a.readline() ) != null){
    ^




    please help!!!





  2. #2
    Ako Guest

    Re: BufferedReader


    1- it is java convention that every class name should starts with a
    capital letter so call your class "More" instead of "more" (this is
    not an error but it is a good practice to follow conventions)

    2- the error message:
    more.java:6: No variable a defined in class java.lang.System.
    InputStreamReader (System.a));

    means exactly what it says "a" is not a variable in class
    java.lang.System, i guess you are trying to read from the consol so it
    should be :

    BufferedReader a = new BufferedReader (new
    InputStreamReader (System.in));

    3- the second error mesage:
    the correct method name is "readLine()" with capital (L)

    good luck,

    Ako



    "Lindsey" <Zave4@aol.com> wrote:
    >
    >Ok. Here is my code. I need to know why i keep getting the same error

    message.
    > The error message is also posted.
    >import java.io.*;
    >public class more{
    > public static void main(String [] args){
    > BufferedReader a = new BufferedReader (new
    > InputStreamReader (System.a));
    > String oneline;
    > int countline;
    > int countcol;
    > countcol = 0;
    > try{
    >
    > while ((oneline = a.readline() ) != null){
    > oneline = a.readLine();
    > System.out.println(oneline);
    > if (countcol >= 80){
    > System.out.println(" ");
    > countline =+ 1;
    > if (countline == 20){
    > break;
    > }
    > }
    > }
    > }
    > catch( Exception e )
    > { System.out.println(e);}
    > }
    >}
    >
    >
    >
    >Error...
    >
    >more.java:6: No variable a defined in class java.lang.System.
    > InputStreamReader (System.a));
    > ^
    >more.java:13: Method readline() not found in class java.io.BufferedReader.
    > while ((oneline = a.readline() ) != null){
    > ^
    >
    >
    >
    >
    >please help!!!
    >
    >
    >
    >



  3. #3
    Paul Clapham Guest

    Re: BufferedReader

    And you didn't ask this yet, but there's a reason your program is only
    processing every other line of the input. That's because you read a line
    into the variable "oneline" in your while-clause, then in the very next line
    of code, you read another line into that same variable. So you will only be
    processing the even-numbered records and ignoring the odd-numbered records.

    PC2

    Lindsey <Zave4@aol.com> wrote in message news:3a994067$1@news.devx.com...
    >
    > Ok. Here is my code. I need to know why i keep getting the same error

    message.
    > The error message is also posted.
    > import java.io.*;
    > public class more{
    > public static void main(String [] args){
    > BufferedReader a = new BufferedReader (new
    > InputStreamReader (System.a));
    > String oneline;
    > int countline;
    > int countcol;
    > countcol = 0;
    > try{
    >
    > while ((oneline = a.readline() ) != null){
    > oneline = a.readLine();
    > System.out.println(oneline);
    > if (countcol >= 80){
    > System.out.println(" ");
    > countline =+ 1;
    > if (countline == 20){
    > break;
    > }
    > }
    > }
    > }
    > catch( Exception e )
    > { System.out.println(e);}
    > }
    > }
    >
    >
    >
    > Error...
    >
    > more.java:6: No variable a defined in class java.lang.System.
    > InputStreamReader (System.a));
    > ^
    > more.java:13: Method readline() not found in class java.io.BufferedReader.
    > while ((oneline = a.readline() ) != null){
    > ^
    >
    >
    >
    >
    > please help!!!
    >
    >
    >
    >




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links