Results 1 to 2 of 2

Thread: Saving a File

  1. #1
    sneeak is offline Member
    Join Date
    Aug 2011
    Posts
    8
    Rep Power
    0

    Default Saving a File

    Hi guys/girls..

    I have been writing code for my program to save a Linked List into a text file.

    Here are the errors I am getting..

    E:\Property Manager\PropertyManager.java:203: cannot find symbol
    symbol : method getPropertyNumber()
    location: class Property
    PropertyNumber = p.getPropertyNumber();
    ^
    E:\Property Manager\PropertyManager.java:204: cannot find symbol
    symbol : method getStatus()
    location: class Property
    Status = p.getStatus();
    ^
    E:\Property Manager\PropertyManager.java:205: cannot find symbol
    symbol : method getPropertyOwner()
    location: class Property
    PropertyOwner = p.getPropertyOwner();
    ^
    E:\Property Manager\PropertyManager.java:206: cannot find symbol
    symbol : method getDate()
    location: class Property
    date = p.getDate();
    ^
    E:\Property Manager\PropertyManager.java:207: cannot find symbol
    symbol : method getAddress()
    location: class Property
    Address = p.getAddress();
    ^
    5 errors

    Tool completed with exit code 1


    and here so my code so far..




    Here is my Code for my button called Save Property.
    My Linked List is called propList.
    I have a separate Java file called Property.java

    Java Code:
    // Save Property Button
    		button5.addActionListener(new ActionListener()
    		{
    			public void actionPerformed(ActionEvent e)
    			{
    				try
    				{
    					PrintWriter out = new PrintWriter(new FileWriter("Property.txt"));
    
    					int PropertyNumber = 0;
    					String Status = "";
    					String PropertyOwner = "";
    					String date = "";
    					String Address = "";
    
    					for (int i = 0; i < propList.size(); i++)
    					{
    						Property p = propList.get(i);
    
    						PropertyNumber = p.getPropertyNumber();
    						Status = p.getStatus();
    						PropertyOwner = p.getPropertyOwner();
    						date = p.getDate();
    						Address = p.getAddress();
    
    						out.println(PropertyNumber + "," + Status + "," + PropertyOwner + "," + date + "," + Address);
    					}
    					out.close();
    
    					JOptionPane.showMessageDialog(null,"Data saved successfully!","", JOptionPane.INFORMATION_MESSAGE);
    
    					}
    					catch (Exception ex)
    					{
    						System.out.println("Save file failed");
    		   		}
    			}
    		});

    Is anyone able to tell me on why these variables cannot be found? I have searched through my code and am not sure as to why the program cannot find them. The variables are declared in the button. It is saying it can't find the get() method.

    How could I go about fixing this?

    Please any help would be appreciated!

    Thanks Casey

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Quote Originally Posted by sneeak View Post
    E:\Property Manager\PropertyManager.java:203: cannot find symbol
    symbol : method getPropertyNumber()
    location: class Property
    The Property class does not have a method called getPropertyNumber()
    E:\Property Manager\PropertyManager.java:204: cannot find symbol
    symbol : method getStatus()
    location: class Property
    The Property class does not have a method called getStatus()

    etc

    The error messages are self-evident. You need to learn how to read the messages you get, what they mean and how to fix them. Nobody will hold your hand forever.

Similar Threads

  1. Saving JTextArea as a txt file
    By chirag123 in forum AWT / Swing
    Replies: 4
    Last Post: 04-28-2011, 04:39 PM
  2. NEW to writing/saving to a file
    By hayden06f4i in forum New To Java
    Replies: 28
    Last Post: 12-06-2010, 03:23 AM
  3. Saving a file in a gui
    By rav in forum AWT / Swing
    Replies: 9
    Last Post: 07-07-2010, 05:27 PM
  4. Replies: 8
    Last Post: 02-18-2010, 12:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •