; expected

Hi people,

I keep getting the following error:

ReadBytes.java:23: ';' expected
            {
            ^
1 error

On the following piece of code:

import java.io.*;
import java.util.*;

public class ReadBytes {
    public void readfile(String input_file) throws IOException {
        try {
            //create a BufferedReader using System.in
            BufferedReader brfin = new BufferedReader(new InputStreamReader(System.in));
            String input_file;
            System.out.println("Enter input file:  ");
            do {
                input_file = br.readLine();
            }
           
            //BufferedReader brfout = new BufferedReader(new InputStreamReader(System.in));
            //String output_file;
            //System.out.println("Enter output file:  ");
            //do {
              //  output_file = br.readLine();
            //}
           
            while (!input_file.matches("null"))
            { // <--------------------------------------------------------------------------Line 23
                FileInputStream fin = new FileInputStream(input_file);
                boolean eof = false;
                int count = 0;
                while (!eof) {
                    int input = file.read();
                    System.out.println(input + "   ");
                    if (input == -1)
                        {eof = true;}
                    else
                        {count ++;}
                }
            }
        }
        catch (IOException e) {}
    }
    public static void main(String[] args) throws IOException {
         ReadBytes filereader = new ReadBytes();

         //String fin = null;
         
         if (args.length > 0) {
            input_file = args[0];
         }
         else {
            printf("Error: No input file specified");
            System.exit(0);
         }
         /*if (args.length > 1) {
            output_file = args[1];
         }
         else {
            printf("Error: No output file specified");
            System.exit(0);
         }*/
         filereader.readfile(input_file);
      }
}

However.... I just cnnot see this being an error. It is extremely urgent i get this corrected.

Thank you in advance,

Andy
acrxxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aozarovCommented:
while (!input_file.matches("null")) -> while (!input_file.matches("null"));
0
aozarovCommented:
0
aozarovCommented:
Actually I think you are missing the while for the first do.
replace
do {
                input_file = br.readLine();
            }

with
input_file = br.readLine();


do does not come by itself.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

aozarovCommented:
I meant: "do" does not come by itself.
This is why Java thinks the while that comes after belongs to it and is looking for the ';'
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
acrxxAuthor Commented:
Sorry about this.... but I am sure you donnot put a semi-colon at the end of a while statement.
0
aozarovCommented:
do { } while(XXX); -> always gets a semi-colon (read http://java.sun.com/docs/books/tutorial/java/nutsandbolts/while.html )
but while (XXX) { } -> don't get semi-colon.

In any case your problem is actually (as I corrected myself) do { ... } without having a while (XXX)
0
NaeemgCommented:
here are sample codes to read and write files, will help you.

http://www.javapractices.com/Topic42.cjp

http://www.rgagnon.com/javadetails/java-0052.html
0
acrxxAuthor Commented:
Sorry about the previous comment.... thanks. It works... I stand corrected.

Thanks for the help
0
aozarovCommented:
NP. :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

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.