Can I print an objects fields' values in a loop without having to cast?

Hi,
I have a Class with about 30 (public)fields and I need to print the values of each of them to a file. I tried the getFields() method of the Class object, but couldn't get the desired result, especially that the documentation says no order is guaranteed when using this method and I need to know have one in order to be able to read from the file when reconstriucting the object.
I considered using the Object Streams but I need it to be in human readable format, preferably ASCII, as the fields are int, long, String, Date...
Also the object might grow so I don't want to hardcode the writing and reading methods, would like it to be as generic as possible.
Thanks for help

hallo,
have you tried XMLEncoder ; something like this (from the API docs):
XMLEncoder e = new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream("Test.xml")));
e.writeObject(new JButton("Hello, world"));
e.close();
you can customize which parts of the objects are written, i think. otherwise, just create bean-like setter and getter methods for the fields and they should be automatically written (and read with XMLDecoder).
ciao, -sciss-

Similar Messages

  • Can not set OARG.cstAllcAcc field value with CustomsGroups Object

    Can not set OARG.cstAllcAcc field value with CustomsGroups Object, please open this field in this Object because it is a key field related to financial system.

    I guess, it should work; instead of html:submit, try with button.

  • How can we read the screen field values from the report selection screen wi

    Hi expart,
    How can we read the screen field values from the report selection screen with out having an ENTER button pressed  .
    Regards
    Razz

    use this code...
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_posnr.
    **Read the Values of the SCREEN FIELDs
    CALL FUNCTION 'DYNP_VALUES_READ'

  • How to Print the same field value in a single row

    Hi,
    I need to print the same field values in a single row
    For Examble
    in a table TestTable
    ID Name Value
    1 AB 120
    1 BC 150
    1 CD 130
    2 AB 111
    2 BC 112
    2 CD 113
    I need the query like if the Name contains BC and CD then i need to print like ID, BC Value, CD Value as below
    ID BC'Value CD'Value
    1 150 130
    2 112 113
    Kindly suggest me...
    Thanks in Advance
    Anu

    Hi,
    Since you're on 9i some available functionality unfortunatly isn't at your disposal.
    This should work, however, using your sample data:
    MHO%xe> create table t as ( -- generating sample data:
      2  select 1 cid, 'AB' cname, 120 cvalue from dual union all
      3  select 1, 'BC', 150 from dual union all
      4  select 1, 'CD', 130 from dual union all
      5  select 2, 'AB', 111 from dual union all
      6  select 2, 'BC', 112 from dual union all
      7  select 2, 'CD', 113 from dual
      8  );
    Tabel is aangemaakt.
    MHO%xe> select cid
      2  ,      max(decode(cname, 'BC', cvalue, null)) BC_value
      3  ,      max(decode(cname, 'CD', cvalue, null)) CD_value
      4  from   t
      5  group by cid;
           CID   BC_VALUE   CD_VALUE
             1        150        130
             2        112        113For reference and future challenges, see:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:419593546543
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php

  • How can you trim the contact field value without cloudconnector?

    How can you trim the contact field value without cloudconnector?

    You can add your contacts to segments, while right-clicking on the criteria you have added in segments, you will see the option for Merge, Intersect & Trim.
    See the attached URL, it might help you .
    Merge, Intersect, Trim

  • Can I use the same iTunes account for 2 iPads without having the same apps on both?

    Can I use the same iTunes account for 2 iPads without having the same apps on both? Everytime I try to sync my new iPad, it syncs all the apps that are on my account. If I can do this, can someone tell me how please???

    Yes you can, easily.  When you plug the first pad in to sync, note the name of the pad on the last pane.  Set up for that device whatever you want to sync.  When you are done, plug the second pad in.  Make sure it has a different name on the left pane.   Then sync to that pad whatever you want.  I tunes will remember what you did on each pad, and will start from there the next time you plug in.

  • How can I list the songs in an album in iTunes without having to do it one by one? Some albums are not numbered.

    How can I list the songs in an album in iTunes without having to do it one by one? Some albums are not numbered or they show 1. 1. 1. 1. 1. 1. 1.

    Poor metadata needs to be corrected if the album is to display properly in iTunes. iTunes sees an "album" as any collection of tracks with the same Album title and the same Album Artist (or Artist if Album Artist isn't set). Each track of the album should have distinct Track V of W and Disc X of Y vaules. W,X,Y are optional, but X may be needed for multi disc albums.
    See Gropuing tracks into albums for details.
    tt2

  • How can I sync my ipod nano to a new computer without having my old computer?

    Need help! How can I sync my ipod nano to a new computer without having my old computer?

    follow the steps given here...
    Syncing to a "New" Computer or replacing a "crashed" Hard Drive

  • ICal Lion is infuriating. How can I add a new event in a chosen calendar without having to create it in my default then edit it?

    iCal Lion is infuriating. How can I add a new event in a chosen calendar without having to create it in my default then edit it?

    We are all entitled to our own opinions. So I respect you there brother
    But then again, Apple has its own basis. iOS is what's selling like pancakes not Macs, so if the gazillions out there are using iOS device and have gotten used to the calendar in their iOS devices. Wouldn't you think it made sense if Lion has the same calendar look and feel?
    Everything was considered and weighthed when they developed Lion. They even mentioned it in the press, They were blown away with the success of iOS so they are extending it to OSX.
    Quite frankly, I like the old iCal but yeah I don't expect anything in SL to stay in Lion otherwise it'll be another Cat name related to Leopard
    People should start looking at this perspective and not get STUCK in the old OS.

  • I have just updated my software on my iPhone 4S to IOS7.0.4 now I have lost many of my contacts.   Can anyone suggest an easy way to reinstate them.  (Without having to add them all again as I don't know what I have lost until I need it).

    I have just updated my software on my iPhone 4S to IOS7.0.4 now I have lost many of my contacts.   Can anyone suggest an easy way to reinstate them.  (Without having to add them all again as I don't know what I have lost until I need it).

    Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.

  • Hi, can I move my iTunes library to an external hardrive without having to consolidate it as my prehistoric computer just doesn't have the space even though I have deleted everything possible to make room? Please help :(

    Hi, can I move my iTunes library to an external drive without having to consolidate it as my prehistoric computer just doesn't have enough space even though I have deleted everything possible to make room? Please help

    Hi, do you know if this works if I then want to move my library to a new computer as that is my main intention bacause my old computer hasn't got enough space for me to add new albums so I want to ditch the computer (its got to be about 100 years old and doesn't seem to cope well with modern technology!!) and start using my laptop for my iTunes. I am at the point now where i'm ready to throw both my computer and iPod out the window!!!! I might point out as well that in trying to clear space on my computer I accidently deleted the Bonjour programme which is aparently needed to use the home share option, oops!!!!
    Thanks, Kerry

  • I purchased an auto-renewing magazine subscription through a Newsstand app on my iPad. I have downloaded the iPhone version of that app. Can I now read the magazine on my iPhone, too, without having to purchase another subscription to the same magazine?

    I purchased an auto-renewing magazine subscription through a Newsstand app on my iPad. I have downloaded the iPhone version of that app. Can I now read the magazine on my iPhone, too, without having to purchase another subscription to the same magazine?

    What does the description for the magazine and/or the magazine's website say ? Some allow you to download on more than one device, but some magazines/newspapers only allow you one download of each copy.

  • Hi  I am a keen photographer and I have just bought you SD card reader for ipad. This works well but was winding if there is an app that I can view the images on the SD card full screen without having to import them to the iPad or is there a way to do thi

    Hi
    I am a keen photographer and I have just bought you SD card reader for ipad. This works well but was winding if there is an app that I can view the images on the SD card full screen without having to import them to the iPad or is there a way to do this on the iPad
    The reason for buy this was for when I was out and about to get a better view off my images.
    I have a iPad 2 16gb
    Hope you can help!
    Thanks

    A couple of weeks ago, (after reading a review in TUAW) I bought a wireless hub/ SD card reader called RAVPower.  its app comes with a built in viewer, so you can load it up, and see the pics full screen. 

  • Can I find out the peak of Output 1-2 without having to play whole track?

    Can I find out the peak of Output 1-2 without having to play whole track? I am preparing my album for mastering and I was told to have each track peak at no more than -2dB. Is there an offline peak detector or maybe another trick people use?

    You should deliver your mixes to the mastering house in 24bit format. They should be converted to 16bit and dithered AFTER the mastering. Also, as long as the mixes are not overloaded, the levels could be handled in mastering also. That's what mastering is about, matching the perceived levels between the tracks. As far as your last question, "Do you just slap a multipressor on the output at that point and call it mastered?" the answer is heck no. I'd suggest selecting some professionally mastered cds in your genre, and put a few into your "mastering song" in logic and use them to compare to your mixes. Play with the mastering tools (multi compressor, EQ, adlimiter, etc) on your tracks and try to bring them into the ballpark with the reference songs. It will take a while to get a handle on it, but with practice, it will get you there.

  • I can not add a new credit card to my iPad without having to block directly with the bank card I'm using.

    I can not add a new credit card to my iPad without having to block directly with the bank card I'm using.

    What does this mean..?
    Gaby0526 wrote:
    ...  without having to block directly with the bank card I'm using.
    Changing Account Information  >  http://support.apple.com/kb/HT1918
    Accepted forms of payment  >  http://support.apple.com/kb/HT5552
    If necessary...
    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

Maybe you are looking for