1 Replies - 441 Views - Last Post: 23 July 2011 - 09:56 AM Rate Topic: -----

#1 clynnridge_08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-June 11

I am getting an error in my code. Pleas help me asap!

Posted 23 July 2011 - 09:40 AM

Hi, I am getting the following error messages in my code. Can you help me please. Also explain why I am getting these errors so that I will know what to do and what I did to get these errors. This is my final project for my class. Thank you in advance.

FinalProject.java:4: '{' expected
private class FinalProject(String filename);

and

FinalProject.java:49: reached end of file while parsing
}
^




import java.io.*;
public class FinalProject
{
 	private class FinalProject(String filename);

   public static void main(String[] args);
	{
		new FinalProject("payroll.dat");

    {
       InputStream istream;
        OutputStream ostream;
        File outputFile = new File("Payroll.dat");
        int k;
        istream = System.in;
        try
        {
           ostream = new FileOutputStream(outputFile);
            System.out.println("Add payroll Amount");
            try
            {
          
				   while ((k = istream.read())) !$= -1;
                    ostream.write(k);
            }
            catch(IOException e)
        {
         System.out.println("Error:" + e.getMessage());
        }
            finally
            {
               try
                {
                   istream.close();
                    ostream.close();
                }
             catch(IOException e)
               {
               System.out.println("File did not close");
               }
            }
        }
        catch(FileNotFoundException e)
        {
           System.exit(1);
        }
    }
	}





Is This A Good Question/Topic? 0
  • +

Replies To: I am getting an error in my code. Pleas help me asap!

#2 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: I am getting an error in my code. Pleas help me asap!

Posted 23 July 2011 - 09:56 AM

The second error means your "{" do not match, this is because you open a { and do not close it

The first error comes from here:
 private class FinalProject(String filename); 
Did you mean to create a constructor here?

If so, then it should look like:
 FinalProject(String filename){
//code for constructor here
} 

Was This Post Helpful? 2
  • +
  • -

Page 1 of 1