Read an Object that is Serialized

Hi All,
I am trying to read back in a file that has been serialized and created by ObjectOutputStream.
So I am using Object Input Stream.
The catch is this file was created with a call to a class that does a List, which calls another class.
How can I read this file back? The List part is throwing me off.
Any examples or help would be great.
Here is my try statement:
FileInputStream inFile = null;
ObjectInputStream input = null;
try{
inFile = new FileInputStream("RDD_BeamPositionTrackReportMessage.bin");
input = new ObjectInputStream (inFile);
//deserialize the List
BeamPositionTrackReportMessage test = (BeamPositionTrackReportMessage)input.readObject();
I want to read the whole file.
Thanks
Tim

Hi,
Here is my samples:
ReportMessage.java
import java.util.*;
import java.io.*;
public class ReportMessage implements java.io.Serializable
public List bPTR = new ArrayList();
Which is used with TrackReport.java:
mport java.util.*;
public class TrackReport implements java.io.Serializable{
          long MessageCreationTime;
          int ActivityID;
          float Reserved_1;
          int BeamNumber;
          float Reserved_2;
          int ScanCount;
          long MeasurementTime;
          int ActivityType;
So basically my serialized log looking for ReportMessage Class and not TrackReport Class which has all the variables.
So then I have a java program called ReadFile.java
ile file = new File("TrackReportMessage.log");
FileInputStream fileInputStream = new FileInputStream(file);
BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
ObjectInputStream objectInputStream = new ObjectInputStream(bufferedInputStream);
BeamPositionTrackReport beamobject = (TrackReport)objectInputStream.readObject();
Maybe I am confused, but with the ReadFile.java I want to read the TrackReport, but some how need to go through ReportMessage first. Basically the List is being Serialized.
Hope this makes more sense.
Thanks
Tim

Similar Messages

  • Reading Inactive objects using repo API

    Hi,
    Is there a way to read inactive objects that resides inside a package using XSJS repo APIs. Also, How do we delete such objects. I have written code that would do the same for active version of objects only. But, not sure how to perform the same for inactive objects. Little pointer in this direction would be great.
    Thanks in Advance,
    Vikas.

    The Repository XSJS APIs are not documented nor released for external usage. Please do not discuss SAP internal only APIs on the public forums.  As you are an SAP employee you should use the internal forums for such internal API questions. 
    I would add that even internally at SAP we aren't supposed to use the XSJS Repository APIs any longer.  Please convert your code to use the REST Repository APIs instead.

  • Can't read all attribute of my serialized object

    Hello everybody,
    I've got a problem with my program. I try to serialized a MutableTreeNode root in order to save and then open my JTree.
    I serialize it and i have no problem but when i open it the parent hierarchy is saved (x is son of y...) but their name are null. I loose nodes' name... :/
                   try {
                        //Je cr�e un fichier temporaire dans le r�p�rtoire courant
                        //Ce fichier est l'arbre (selection de l'utilisateur) serializ�
                        //Flux cr�ant un fichier
                        FileOutputStream fos = new FileOutputStream(this.path);
                        //Flux dans lequel je stocke un objet
                        ObjectOutputStream oos = new ObjectOutputStream(fos);
                        //J'�cris dans mon flux mon objet
                        System.out.println("root before drag = "+this.root); 
                        oos.writeObject(this.root);
                        //On ferme le flux
                        oos.flush();
                        fos.close();
                   } catch (FileNotFoundException e1) {
                        System.err.println("FileNotFoundException");
                        e1.printStackTrace();
                        return null;
                   } catch (IOException e1) {
                        System.err.println("IOException");
                        return null;
                   } catch (ClassCastException e1) {
                        System.err.println("ClassCastException");
                        return null;
                   try {
                        FileInputStream fos = new FileInputStream(this.path);
                        ObjectInputStream oos = new ObjectInputStream(fos);
                        //J'�cris dans mon flux mon objet
                        MutableTreeNode sousArbre = (MutableTreeNode) oos.readObject();
                        //On ferme le flux
                        fos.close();
                        //On r�cup�re l'arbre
                        System.out.println("root after drag = " + sousArbre);
                        this.root = sousArbre;
                        modele = new DefaultTreeModel(root);
                        Arbre.setModel(modele);
                        Aide a = new Aide(Arbre);
                   } catch (FileNotFoundException e1) {
                        System.err.println("FileNotFoundException");
                        e1.printStackTrace();
                   } catch (IOException e1) {
                        System.err.println("IOException");
                        e1.printStackTrace();
                   } catch (ClassNotFoundException e1) {
                        System.err.println("ClassNotFoundException");
                        e1.printStackTrace();
                   } catch (ClassCastException e1) {
                        System.err.println("ClassCastException");
                        e1.printStackTrace();
                   }so:
    System.out.println("root before drag = "+this.root);
    return node name
    Mais :
    System.out.println("root after drag = " + sousArbre);
    return null
    Have you an idea ?
    Thx :)

    Please check your Node Object, I mean all Objects that you are going to save is serialized or not.

  • Read a field of a serialized object

    Hi,
    is-it possible to read separately a field of a serialized object? By exemple, if I serialize an object that contains a String field, can I read only this String field?
    Thanks
    Jean

    You can do so, if you re-implement Java's serialization spec. That or overload readObject() and wait for your individual field to come in, trap the result and forward it on.
    As you can see from either of these alternatives, there is not a good way to do this. It's like asking 'how can I get an XML fragment from a file?" That task is, on the face of it, far easier. But it equally does not make sense.
    If you have control over the serialization, and you have a key lookup field, serialize it separately in an index-like file or serialize it ahead of Java's serialization in the same file.
    - Saish
    "My karma ran over your dogma." - Anon

  • Serializing objects that use Loggers

    i am trying to clean-up a lot of java code i have written. so please allow me one more post:
    the issue is objects that use Loggers :
    public class MyClass implements Serializable {
      private static Logger logger = Logger.getLogger("baselib.utilities"); // <-- must be marked transient
    }no serializable objects can use Loggers , right? in my imagination i see that:
    (1) Logger settings are global to a jvm . [read out of a "logging.properies" at start-time].
    (2) so, a MyClass object is created in jvm1 and gets its log settings.
    (3) it is serialized and sent to jvm2.
    (4) it pops-up after de-deserialization, and the jvm2 global log settings are different.
    the Logger in the MyClass object is hopelessly confused.
    so, by hook or crook,
    its fair to say that you cannot use Loggers with serializable objects, right?
    (i don't like Loggers anyway).
    please just answer this one last question, then i can get back to writing code rather
    than cleaning it. thanks to all.

    i am running at least 4 threads (and sometimes as many as 20) leading to chaotic
    asynchronous output. and this Logger output is very hard to look at. in production, then it makes sense.
    CONFIG: Main::_loadConfigSettings()__checking config file :: remoteRunnPort = #7002
    Jun 8, 2008 11:31:48 AM kuai.Main loadConfigSettings
    CONFIG: Main::_loadConfigSettings()__checking config file :: fileSharePort = #7001
    Jun 8, 2008 11:31:48 AM maui.engine.FileShareService run
    FINER: ----FileShareService::_run()___running....
    Jun 8, 2008 11:31:48 AM maui.engine.DataService openNewConnections
    FINER: ____----DataService::_openConnections()___opening 3 new connections___pool size = 0__idle = 0
    Jun 8, 2008 11:31:48 AM maui.engine.FileShareService run
    FINEST: ----FileShareService::_run()___LISTENING on port #7001....
    Jun 8, 2008 11:31:48 AM maui.engine.DataService openNewConnections
    FINEST: ____----DataService::_openConnections()___new connection___pool size = 1__idle = 1
    Jun 8, 2008 11:31:48 AM maui.engine.DataService openNewConnections
    FINEST: ____----DataService::_openConnections()___new connection___pool size = 2__idle = 2
    what i want to see:
    Main::_loadConfigSettings()__checking config file :: resultsHandlerPort = #7002
    Main::_loadConfigSettings()__checking config file :: fileSharePort = #7001
    ----FileShareService::_run()___running....
    ____----DataService::_openConnections()___opening 3 new connections___pool size = 0__idle = 0
    ----FileShareService::_run()___LISTENING on port #7001....
    ____----DataService::_openConnections()___new connection___pool size = 1__idle = 1
    ____====____====________ResultsHandler::_run()__starting....
    _______________________________UserThread-01::_run()__starting....
    ____----DataService::_openConnections()___new connection___pool size = 2__idle = 2
    ____----DataService::_openConnections()___new connection___pool size = 3__idle = 3
    ____====____====________ResultsHandler::_run()__LISTENING on port #7002
    i don't know how to use the NetBeans debugger with so much threading (or really at all).
    so, i use the good-old: " +System.out.println():+ "
    and, once i get a thread working ok, i comment out all the print lines:
    // ____----DataService::_openConnections()___new connection___pool size = 2__idle = 2
    // ____----DataService::_openConnections()___new connection___pool size = 3__idle = 3
    the Logger gives way too much output, and i need to do like:
    "thread #1 = nothing ; thread #2 = *FINEST* ; thread #3 = *INFO* ; ...."
    if some can tell me a better way to debug heavily threaded code, that would be the
    greatest gift of all. i get confused too often and waste so much time.
    JUnit testing threaded code.. its just not possible with so much asynchronousity (right?).
    Edited by: pdFrog on Jun 8, 2008 5:14 PM

  • Possible?Multi-Entity View Object with one Entity Object that is Read-only.

    I know this sounds crazy, but I would like to create a multi-entity view object, where one entity object is based on a table in my application (we'll call it "Users", which basically stores the primary key for the person from the institutional people database), and the other table is a entity object based on a view of the institutional people database table (read only access), which we can call "People".
    I know that since no updates will be done to the People table, it really should be a read-only View Object, but I would lose the ability to sort on attributes like Last Name, Hire date, etc, since those would be transient attributes in my ViewObject for the Users. By having People as an entity object, I can then create a multi entity view object and have the ability to join Users to People and be able to sort on the above mentioned fields (like Last Name).
    The problem is that when I use the JDev (I'm currently using 10.1.2.1) AppModule BC4J tester, when I click on the multi-entity view object that I added to the AppModule it gives me an error:
    oracle.jbo.RowCreateException) JBO-25017: Error while creating a new entity row for People.
    ----- LEVEL 1: DETAIL 0 -----
    (java.lang.InstantiationException) null
    I have tried to change all the attributes to updateable in my entity object, but no create method, and I have tried to make them all read-only, but no effect, I get the same error (probably because the People view is read-only in my schema).
    Is there a way to change the entity object so that it will not try to create a new row when it runs the Tester? So that the multi entity view object behaves more like a view link, but gives me the added bonus of being able to sort on the Last Name column from the People table?
    Thanks for any help on this subject...at worst, I will have to use the view link method to get the job accomplished, but it would be "cooler" if this would work!
    Jeremy.

    Steve, thanks for your quick response to my question.
    To answer your questions, I was trying to create the Multi-entity View Object to give me more flexibility when working with my User table, and my People view. The flexibility I desired was that I would be able to sort my Users based on attributes in the People view. This is not possible when the there is only one Entity in my VO, and the People view data are all transient attributes, because they are not in the SQL statement.
    Ultimately, after working with one of my colleagues, we decided to use the approach that you mentioned by creating a read-only VO with the SQL query we want to display to the user (contains both User and People data fields), and then use a different ViewObject when performing other actions on the User Table (such as inserts/updates/deletes). By using the setWhereClauseParam() method in the handleLifeCycle() for the JSP page, we should be able to navigate between the different View Objects, so that the user does not see any difference.
    Thanks! Oh, and by the way, I have read your article you included before, and I have used it many times before to tune my View Objects! Thanks!

  • Reading an object from a binary file

    i am writing objects into my binary file using printwriter class. i am able to write objects into the file but i am having problems reading the object from the file. is there any other way of going about it. i tried using the objectoutputstream and object input stream class. but i am getting run time errors coz of something to do with serialization
    i am storing records as a object into a binary file so that it is easy to seek my records

    Of course you have trouble reading objects after you wrote them with a PrintWriter.
    You should rather have fixed the Serialization errors: only objkects that implement Serializable correctly can be serialized.

  • When I am trying to use the 'Up to Date' Program, it says that my Serial Number is invalid.

    I give the online form all of my information, but it says that my Serial Number cannot be verified. I don't want to pay $29.99 heehee. And I purchased my MacBook Pro on June 11, 2011...

    That was it, Thought it was smarter than that.
    Thanks for your help.

  • I am trying to install CS2 but I receive a message that my serial number is invalid.

    I have been trying to install CS2 on Win XP. (My old laptop died, I still have the original disks, serial #, etc. but was unable to use because of the activation problem). I downloaded all the files from the website referenced above and tried to follow the instructions here and in the pdf. However the files that downloaded to my computer did not have the names that are mentioned in the pdf. The files that downloaded were called CreativeSuiteCS2Disc1, CreativeSuiteCS2Disc2, CreativeSuiteCS2Disc3, CS2.0_WWE_Extras_1 and VCS2. Also, I was never given an option to "install later".
    However I was able to "extract" the files. They extracted into different folders, and after reading through this whole thread I was able to move the files around in the folders until they look like those in message 123 later in this thread that pictures all of the files that should be in a folder together (mine are in C:\Creative Suite CS2\Adobe Creative Suite 2.0).
    However I still can't get it to work. If I try to run the installer in any of the programs (for example Photoshop or Illustrator), when I enter the serial number given on the website I get the message that the serial number is not valid.
    Help!!
    Thanks!

    Thanks very much. Yes, I am using the installer files and serial number from the URL you referenced above. I have spent many hours trying to get it to work. I would love some help!!
    The problem is that the instructions that come in the pdf with the downloaded files do not work, because the files that download from that page do not have the names referred to in the pdf, and most of the things that are referred to in the instructions do not happen. Here is what actually happened.
    When I downloaded the files from the website, these are the files that downloaded:
    I double-clicked each one and they extracted into two different folders.
    Then I read a message on the forum that said to move all the extractred files into the same folder, so I moved all files into one file at C:\Creative Suite CS2\Adobe Creative Suite 2.0 as was pictured in the forum message. Here are screen shots showing all of the files in that folder I have now:
    So then I double clicked the "Setup" file and I got this error message:
    So then I tried to install the programs separately from the installer inside the folders Photoshop and Illustrator. I got this far and entered the serial number from the website:
    But then I got this error message, even though I was using the files and serial number exactly from the website:
    I tried both photoshop and illustrator and the same thing happened.
    (I also looked at Solution 2 that you mentioned above but I don't have anything called VCOM on the computer. Also the error message that I got is not that one.)
    I think I really need a set of instructions that lists the steps in order to do, but based on the files that actually download from the website and what happens when you extract the files. I feel as if I have all of the proper files but it still doesn't work.
    Thank you very much!

  • Determine all objects that a group has been assigned to

    I am trying to determine all objects that a group has been assigned to. For example, I would like to know what communities and portletes a group has been assigned to.
    I can retrieve the information directly from the plumtree database, however, I have not been able to determine how to accomplish this via the api.
    I have tried the following
    IPTObjectManager ptObjMng = ptSession.GetCommunities();
    for(inti = 0; i<3;i++)
    filter[i] = newObject[1];
    filter[0][0] = PT_PROPIDS.PT_PROPID_USERGROUP_GROUPID;
    filter[1][0] = PT_FILTEROPS.PT_FILTEROP_EQ;
    filter[2][0] = 1634; //group id for my group
    IPTQueryResult ptResult = ptObjMng.Query(PT_PROPIDS.PT_PROPID_ALL,-1,PT_PROPIDS.PT_PROPID_NAME,0,-1,filter);
    I have verified that the group has been assigned to the community, however, this query returns no records.
    How can I retrieve all communities or group that a specific group has been assigned too?
    thanks in advance

    This sure would be a handy feature! iTunes has it so that you can easily tell which playlists a song is in. It would be convenient for iPhoto as well.

  • Crystal Report: failed to read parameter object

    Hello -
    I have a report that consists of numerous static parms and one dynamic parm. I can save the report to my desktop but cannot save it to BO 3.1 CMC Personal Folder (or any folder for that matter).
    The dynamic parm does not use a LOV based on Business Views. A table associated with the same data source as the stored proc on which the Report itself is based provides two fields - a code field that is used in the Value and a name field which is used in the Description.
    The specific error is:
    "Failed to read data from report file <file name> Reason: failed to read parameter object".
    All the normal things have been checked -
    - VERIFied the database
    - Ensured 'No Printer' is checked
    - Ran the report (successfully) on the desktop (locally)
    The data source is Oracle. The report can be saved to the CMC and run without problem if the dynamic parameter is deleted from the report.
    The version of Crystal Reports is CR 2008 vers 12.04
    I've seen numerous postings regarding LOVs and Business Views, especially surrounding security issues, but I've yet to see a note about a dynamic parameter based on a table....
    Thanks

    Hi!
    Thanks for the response....
    Re: check the "Enable Repository Refresh" checkbox
    The SAVE failed with the Failed to read data from report file error.
    When I went to the Bus View mgr, I found the LOV. It was set as a cascading prompt (not what I wanted when I set the parm) and could not edit it. No permissions.
    I went back to the report and tried to edit the parm into which I had stuffed the LOV I can't touch in Bus Views, and found I can't open in the report canvas without logging into the repository.... which I did.... and went to edit the parm...can't open in the report canvas without logging into the repository.... which I did.... and went to edit the parm... You get the idea....
    What I had WANTED to do is take a table with 2 fields in it - a NAME and a CODE field, create a dynamic parm, use the CODE field as the Value and the NAME field as a description. When I brought in the LOV, it came in as a cascading LOV... I needed to have the Description as the user fronted piece... but I can't seem to get there from here.....

  • My hard drive's gone, I did repair it and now I'd like to get my 'photoshop Elements 7 back, but got a message saying that the serial number is incorrect and it's not. can you help me, please?

    My hard drive's gone, I did repair it and now I'd like to get my 'photoshop Elements 7 back, but got a message saying that the serial number is incorrect and it's not. can you help me, please?

    Mseixas you can try running the CC Cleaner Tool located at Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6 - http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html and then reinstalling.

  • Problem in reading an object inside another obj in C thru JNI

    Hi All,
    I am passing a java class object from Jave to C thru JNI.
    This object has many integer fields + one object of another class, which also has some fields.
    I am able to read integer fields from C but not able to read fields inside another object.
    Can anyone plz help me in reading the object inside another object from C.
    I m pasting class here for better understanding :
    public class ImageMergeInformation {
    public ImageInformation outputImageInfo;
    public ImageInformation[] inputImageInfo = new ImageInformation[8];
    public int topMargin;
    public int bottomMargin;
    I wanna read ImageInformation obj.
    Plz help me...
    Thanks in Advance,
    Regards,
    Sneha

    You have to get the field id (getFieldID) of the variable you want, e.g. outputImageInfo, then get the object (getObjectField) in that field. At this point, you can start over (get the class, get the field id, get the object).

  • How do you select an object that is directly under another object?

    How do you select an object that is directly under another object?
    I was working from a template and I wanted to make a text box the same size as a column box that was put there in order to keep the text in the confines of the paper that is was being printed to.
    I could actually put text in each column fine but I wanted it to be in a text box so that I could slightly tilt the test box to compensate for my printer feeding it in slightly wrong. I accomplished this on another template but I could not on this one. If I was working in InDesign or something I know I could just select that layer but I'm at a loss of what to do here. How do I select a column right under a text box? I just thought of something. Once I make the text boxes the same size as the columns I think I can just delete the columns from the inspector. But that would be kind of a work around. I know you can hold down command when nothing is selected from outside the document and then highlight but this is not working. Does anyone have some tips and tricks when it comes to having control over which objects you are selecting when it comes to objects that are overlapped as well as directly over each other.
    Thanks.
    Tim

    I'm not sure it's documented any where, but it's not too difficult. First, ⌘-click outside of the layout area to enter object mode then drag the cursor towards the two objects until you see the handles. Now, again ⌘-click on the top object to deselect it. You can now move the underlying object to the front to edit, delete, etc.
    After typing this, it dawned on me, why not just click the top object to select it & move it to the back? I've only done the other way a bazillion times & now I think of this.

  • How to read OLE objects from Access ??

    Hi,
    I have an field of type OLE in my Access Database table. This field has some files stored in it in the form of attachment. The file types of the OLE objects can be different (xls,txt,doc). Now, I want to query the database and find the extension of the files and save it occordingly using java.
    I'm using the following now.
    JdbcOdbcInputStream jois = (JdbcOdbcInputStream) rs     .getBinaryStream("SupportingData");
    byte[] supportingData = jois.readData();
    String data = new String(supportingData);
    I'm getting data in binary format and when I try to look into it, all I can see is the header info of the file.
    Is there anyother way to read the OLE object easily ?
    Please suggest.
    Thanks,
    Mary

    How to read appended objects from file with ObjectInputStream? The short answer is you can't.
    The long answer is you can if you put some work into it. The general outline would be to create a file with a format that will allow the storage of multiple streams within it. If you use a RandomAccessFile, you can create a header containing the length. If you use streams, you'll have to use a block protocol. The reason for this is that I don't think ObjectInputStream is guaranteed to read the same number of bytes ObjectOutputStream writes to it (e.g., it could skip ending padding or such).
    Next, you'll need to create an object that can return more InputStream objects, one per stream written to the file.
    Not trivial, but that's how you'd do it.

Maybe you are looking for

  • Reading attributes of different context nodes

    Hello, I want to read attributes of BP_DATA/TaxNumberList Node: BUILHEADER from Node BUILTAXNUMBER. I have tried all without success. In GENIL Browser they are not related. What can i do? Best Regards JM

  • Error while trying to provision OIM user to Active Directory using SSL

    Hi All, I am able to see the users through LDAP browser using SSL but am getting the following error while trying to provision OIM users to AD using SSL. I am using Microsoft Active Directory connector type 9.11. Response: Connection Error encountere

  • Pivot min & max in single row.

    Greetings, Please help me in this case... Can we get the columns as, Dimension, # Count, MAX (# Count), MIN (#Count) all in one line with separate values but separate min, max & count in pivot. also imagine for multiple rows . this report is seen on

  • Sun ONE Portal Server 6.0 and struts.

    Hi all, Has anyone tried using struts with Portal Server? Can we use/migrate struts application to Portal Server 6.0? As far as I know both uses one gateway servlet. Pelase reply. Thanks.

  • How can I check to see if my iPad is factory unlocked

    Hi, I'm having problem using a sim in my iPad when there is no Wi-Fi. I have been told that iPads lock to the first sim that is installed. As I have now changed my network provider, could this be the reason my new sim does not work? If this is the ca