Results 1 to 4 of 4
  1. #1
    javaSweden is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Default saving Object[][] via ObjectOutputStream

    Hopefully someone can help me with the following problem:

    here a two scenarios and I am trying to solve the latter. (the question is: Why it takes a lot more time to save an Object-array than a double-array?

    1) putting the information (stockmarket data) in a double[8][3000] . then putting this info in an ArrayList and via ObjectOutputStream write the data to a file.

    [double] [double] [double] [double] [double] [double] [double] [double] [double]

    this takes approx. 4 seconds. OK!!!!


    2) putting the information (stockmarket data) in an Object[8][3000] where the first column is String (date) and the rest is Double. Then via ObjectOutputStream write the data to a file.

    [String] [double] [double] [double] [double] [double] [double] [double] [double]

    this takes approx. 30 seconds. NOT OK!!!


    ..............................

    I suspect that the problem is the ObjectOutputStream. Its no problem (not time consuming) to store the data in an Object [][]. The time-consuming part is when the data is written to a file.

    ---------------------------------------------

    about the data: Stockmarketdata information whis i stored in an two-dim. array with 8 columns and 3000 rows (tradingdays)

    date | open | | high | low | close | volume | nmbr of stocks | adj close.


    The reason why I want to put the information in an Object is because I want to store it graphically in the JTable Class whis takes Object as an argument and at the same time be able to have string values in the first column (date) and double values in the others.

    Regards

    Björn

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

  3. #3
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: saving Object[][] via ObjectOutputStream

    You can write them yourself to disk usinf a buffered stream... I guess this is a lot faster for many items.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,173
    Rep Power
    20

    Default Re: saving Object[][] via ObjectOutputStream

    Create a class representing this data (assuming you haven't already got one).
    Hand a List of that class to your TableModel. Have a TableModel that knows how to pass this data to the Table when asked for it.

    That's part 1.

    Part 2 is try and serialise this class, with all the data. If that's still crap, then do as Sierra suggets and write your own. You;ve only got 8 fields, so that's hardly complex and will save on the overhead of class data that has to be serialised as well.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 4
    Last Post: 08-28-2011, 06:15 PM
  2. Replies: 3
    Last Post: 02-08-2011, 08:45 PM
  3. Replies: 17
    Last Post: 10-14-2010, 11:26 PM
  4. ObjectOutputStream Example
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-20-2008, 10:21 AM
  5. question on ObjectOutputStream
    By money123 in forum New To Java
    Replies: 5
    Last Post: 07-27-2007, 11:31 AM

Posting Permissions

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