[program-java] Re: Writing and reading class instance variables

  • From: "Roger Woolgrove" <rawoolgrove@xxxxxxxxx>
  • To: <program-java@xxxxxxxxxxxxx>
  • Date: Sun, 29 May 2011 11:49:52 +0100

Hi Jim,

I'm not sure if this is what I am thinking either.  I think our wires are a 
little crossed.  This whole debugger thing sounds great, could you tell me 
more.  I haven't got that far with the Eclipse guide.

Cheers

Roger


  ----- Original Message ----- 
  From: Corbett, James 
  To: 'program-java@xxxxxxxxxxxxx' 
  Sent: Wednesday, May 25, 2011 2:17 PM
  Subject: [program-java] Re: Writing and reading class instance variables


  Roger:

  Ok, I'm not quite understanding what you are up to here but if you want to 
read these values during run time so to speak you could run your application in 
debug mode. Obviously you would need to set a break point or two and once you 
have hit the given line you can inspect the elements in question.

  If this is what you are asking, then I can help.

  Jim 



------------------------------------------------------------------------------
  From: program-java-bounce@xxxxxxxxxxxxx 
[mailto:program-java-bounce@xxxxxxxxxxxxx] On Behalf Of Roger Woolgrove
  Sent: May 24, 2011 12:46
  To: program-java@xxxxxxxxxxxxx
  Subject: [program-java] Re: Writing and reading class instance variables


  Hi Jim,

  OK, the xlint compiler error has been dealt with and I'm not sure how I did 
it or what I did but it went away.

  Next,  I am having trouble writing serialised variables, or reading them back 
in.  When I check the size of the .dat file, it appears to have the information 
stored in it as the size suggests this.

  What I am trying to do is write several Lists  and retrieve said lists.  Each 
of these Lists is a list of instances of classes, containing the instance 
variables set therein.

  I have no idea how to  read in debugged or otherwise.

  I'd just like to be able to save my work at the end of the day with all the 
instances of any class saved in a list, then the next day, I'd like to start 
off where I left the day before by loading in all the instances of each class 
into the Lists.

  Does this make anything any clearer?

  Many thanks

  Roger


    ----- Original Message ----- 
    From: Corbett, James 
    To: 'program-java@xxxxxxxxxxxxx' 
    Sent: Tuesday, May 24, 2011 1:11 PM
    Subject: [program-java] Re: Writing and reading class instance variables


    Roger:

    Do yu want to read these vars in debug mode?

    Jim 



----------------------------------------------------------------------------
    From: program-java-bounce@xxxxxxxxxxxxx 
[mailto:program-java-bounce@xxxxxxxxxxxxx] On Behalf Of Roger Woolgrove
    Sent: May 20, 2011 18:38
    To: JavaProgramming
    Subject: [program-java] Writing and reading class instance variables


    Hi all,

    Still learning and I have written a number of classes in my current 
project.  I have a class which I use to compile, sort, read and write instances 
of everything.

    I am using Writer, BufferedWriter etc to write the instances of each class 
kept in a Set to file.

    However, when reading in a file, I am unable to write the appropriate 
syntax to read in certain instance variables.

    Those I speak of include
    public int tdsOpen;
    public Map<String, Integer> tdrOpen;
    public List<String> tflOpen;
    public SortedSet<String> tmmOpen;

    I am successfully using:
    tbrClose = lineScanner.next(); to obtain the next item as a String and
    vlrClose = lineScanner.nextDouble(); to get the next item as a Double.

    So could anyone help me in the correct syntax to obtain the instance 
variables as above.
    The basic set up I am using for reading in for the purpose of names etc is:

             Scanner lineScanner;
             String currentLine;
             bufferedScanner = new Scanner(new BufferedReader(new 
FileReader(aFile)));
             while (bufferedScanner.hasNextLine() )
             {
                currentLine = bufferedScanner.nextLine();
                lineScanner = new Scanner(currentLine);
                lineScanner.useDelimiter(",");
    // then 
    variableName = lineScanner.next();
    etc

    Many thanks

    Roger

Other related posts: