?
Solved

; expected

Posted on 2005-03-28
9
Medium Priority
?
241 Views
Last Modified: 2010-03-31
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
0
Comment
Question by:acrxx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
9 Comments
 
LVL 15

Expert Comment

by:aozarov
ID: 13645766
while (!input_file.matches("null")) -> while (!input_file.matches("null"));
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13645775
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13645792
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 15

Accepted Solution

by:
aozarov earned 2000 total points
ID: 13645800
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
 

Author Comment

by:acrxx
ID: 13645805
Sorry about this.... but I am sure you donnot put a semi-colon at the end of a while statement.
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13645883
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
 
LVL 5

Expert Comment

by:Naeemg
ID: 13645907
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
 

Author Comment

by:acrxx
ID: 13646046
Sorry about the previous comment.... thanks. It works... I stand corrected.

Thanks for the help
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13646052
NP. :-)
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question