-
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!!!
-
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!!!
>
>
>
>
-
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!!!
>
>
>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|