Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Static method throwing "cannot find symbol - method"

807601Jun 30 2008 — edited Jun 30 2008
This is an assignment for school. I'm in my second semester of object oriented programming. Here is the method causing the error when compiled in the test case:
    public void testRead()
    {
        Company aCompany = buildCompany();
        aCompany.writeToFile("CompanyDatabase.txt");
        Company bCompany = new BooksAndMore();
        bCompany = readFromFile("CompanyDatabase.txt");
        assertTrue(aCompany.equals(bCompany));
    }
Error thrown is "cannot find symbol - method readFromFile(java.lang.String). Here is the method being called:

{code} public static Company readFromFile(String fileName)
{
Company company = new BooksAndMore();

FileInputStream fis = null;
ObjectInputStream in = null;

try
{
fis = new FileInputStream(fileName);
in = new ObjectInputStream(fis);
company = (Company)in.readObject();
in.close();
}
catch (IOException ex)
{
ex.printStackTrace();
}
catch (ClassNotFoundException ex)
{
ex.printStackTrace();
}

return company;
}{code}

What am I doing wrong?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 28 2008
Added on Jun 30 2008
4 comments
867 views