Deserializing a file not serialized using Java

Hello ,
I am trying to deserialize and read a file which has been previously serialized using VC++. Is there a way to read a file serialized by VC++ using Java. When i read using ObjectInputStream, exception is thrown (StreamCorruptedException). The file structure of the serialized file is as below:
PC Records(Array)
ObjectRecord
Name;(string)
SecurityLevel;(unsigned char)
SecurityGroup;(string)
ScanTime;(unsigned char)
ElementNum;(int)
PCDevice;(unsigned char)
m_SerNum[5];(unsigned char)
m_DeviceChanCount; (unsigned char)
m_ModelID; (unsigned char)
m_ChanNum; (unsigned char)
m_LastBlock; (unsigned short)
m_ScanTime; (unsigned char)
m_Owner; (unsigned char)
m_Gain; (unsigned char)
PCPath;(string)
m_PCName;(string)
a; (unsigned char)
b; (unsigned char)
could somebody help me deserialize and read this file using Java. Any help and sample source code is greatly appreciated.

This can't be read from Java Serialization API 'cause Java Serialization API has it's on propietary format (that's one reazon why J2SE 1.4 introduced XML serialization)
If you need to read a file serialized in VC++, you will need to implement the code to read the file in Java.
If you only need to read the file secuentially (one record after the other loaded into memory) you can use a java.io.FileInputStream, and wrap it in a java.io.BufferInputStream to optimize reading.
The interface java.io.DataInput have a lot of methods you can use to read the fields (read signed ints, unsigned ints, chars, bytes). You can use then java.io.DataInputStream to wrap InputStream and read this kind of fields. You have to take special care with chars and strings, 'cause they are unicode in java and probably only ASCII on the VC++ generated file. Probably strings will have to be read byte after byte until the \0 mark is reached, unless string fields have a predefined length, in this case you can read [length] bytes from the input stream and create a string from this array.
If you need random access then you need java.io.RandomAccessFile, it also implements java.io.DataInput, so you have the methods to read ints, shorts, bytes, etc.
UTF strings are strings using UTF encoding, so probably this method will not help much in this case.
Rivas

Similar Messages

  • Deserializing a file not serailized by Java

    Hello All,
    I am trying to deserialize and read a file which has been previously serialized using VC++. Is there a way to read a file in Java, serialized by VC++. When i read using ObjectInputStream, exception is thrown (StreamCorruptedException). The file structure of the serialized file is as below:
    PC Records(Array)
    ObjectRecord
    Name;(string)
    SecurityLevel;(unsigned char)
    SecurityGroup;(string)
    ScanTime;(unsigned char)
    ElementNum;(int)
    PCDevice;(unsigned char)
    m_SerNum[5];(unsigned char)
    m_DeviceChanCount; (unsigned char)
    m_ModelID; (unsigned char)
    m_ChanNum; (unsigned char)
    m_LastBlock; (unsigned short)
    m_ScanTime; (unsigned char)
    m_Owner; (unsigned char)
    m_Gain; (unsigned char)
    PCPath;(string)
    m_PCName;(string)
    a; (unsigned char)
    b; (unsigned char)
    could somebody give me a hint to deserialize and read this file using Java. Any help and sample source code is greatly appreciated.

    Hello All,
    Thanks for your comments. When the file is read using RandomAccessFile and data is read into a byte array, how do u find out how many arrays are present inside and read them accordingly (using the foll format):
    PC Records(Array)
    ObjectRecord
    Name;(string)
    SecurityLevel;(unsigned char)
    SecurityGroup;(string)
    ScanTime;(unsigned char)
    ElementNum;(int)
    public class Temp {
    static FileInputStream inFile;
    static DataInputStream inData;
    public static void main (String args[])
    int len=0;
    byte[] buf = new byte[1024];
    try{
    File file = new File("sample1.lmd");
    inFile = new FileInputStream( file );
    RandomAccessFile inData = new RandomAccessFile(file,"r");
    System.out.println("File Descriptor is "+ inData.getFD());
    System.out.println("File Channel is "+ inData.getChannel());
    System.out.println("File Length is "+ inData.length());
    System.out.println("File Pointer is "+ inData.getFilePointer());
    while ((len = inFile.read(buf)) !=-1)
    inData.read(buf, 0, len);
    catch (Exception e) {
    System.out.println("exception is "+e);
    Thanks

  • How to trace changes in directories and files in windows using java.

    Hi,
    Want to know how to trace changes in directories and files in windows using java.
    I need to create a java procedure that keeps track of any changes done in any directory and its files on a windows System and save this data.
    Edited by: shruti.ggn on Mar 20, 2009 1:56 AM

    chk out the bellow list,get the xml and make the procedure.....     
         Notes          
    1     Some of the similar software’s include HoneyBow, honeytrap, honeyC, captureHPC, honeymole, captureBAT, nepenthes.     
    2     Some of the other hacking software’s include keyloggers. Keyloggers are used for monitoring the keystrokes typed by the user so that we can get the info or passwords one is typing. Some of the keyloggers include remote monitoring capability, it means that we can send the remote file across the network to someone else and then we can monitor the key strokes of that remote pc. Some of the famous keyloggers include win-spy, real-spy, family keylogger and stealth spy.          
    3     Apart from theses tools mentioned above there are some more tools to include that are deepfreeze, Elcomsoft password cracking tools, Online DFS, StegAlyzer, Log analysis tools such as sawmill, etc.

  • Creating file browser GUI using java swing tree

    Hi all,
    I have some questions which i wish to clarify asap. I am working on a file browser project using java swing. I need to create 2 separate buttons. 1 of them will add a 'folder' while the other button will add a 'file' to the tree when the buttons are clicked once. The sample source code known as 'DynamicTreeDemo' which is found in the java website only has 1 add button which is not what i want. Please help if you know how the program should be written. Thx a lot.
    Regards,

    Sorry, don't know 'DynamicTreeDemo'import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    import java.io.File;
    public class Test extends JFrame {
      JTree jt = new JTree();
      DefaultTreeModel dtm = (DefaultTreeModel)jt.getModel();
      JButton newDir = new JButton("new Dir"), newFile = new JButton("new File");
      public Test() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        newDir.setEnabled(false);
        newFile.setEnabled(false);
        jt.setShowsRootHandles(true);
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        File c = new File("C:\\temp");
        DefaultMutableTreeNode root = new DefaultMutableTreeNode(c);
        dtm.setRoot(root);
        addChildren(root);
        jt.addTreeSelectionListener(new TreeSelectionListener() {
          public void valueChanged(TreeSelectionEvent tse) { select(tse) ; }
        JPanel jp = new JPanel();
        content.add(jp, BorderLayout.SOUTH);
        jp.add(newDir);
        jp.add(newFile);
        newDir.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            TreePath tp = jt.getSelectionPath();
            if (tp!=null) {
              DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode)tp.getLastPathComponent();
              File newFile = new File((File)dmtn.getUserObject(),"foo");
              if (newFile.mkdir()) {
                dmtn.add(new DefaultMutableTreeNode(newFile));
                dtm.nodeStructureChanged(dmtn);
              } else System.out.println("No Dir");
        newFile.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            TreePath tp = jt.getSelectionPath();
            if (tp!=null) {
              DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode)tp.getLastPathComponent();
              File newFile = new File((File)dmtn.getUserObject(),"foo.txt");
              try {
                if (newFile.createNewFile()) {
                  dmtn.add(new DefaultMutableTreeNode(newFile));
                  dtm.nodeStructureChanged(dmtn);
                } else System.out.println("No File");
              catch (java.io.IOException ioe) { ioe.printStackTrace(); }
        setSize(300, 300);
        setVisible(true);
      void select(TreeSelectionEvent tse) {
        TreePath tp = jt.getSelectionPath();
        newDir.setEnabled(false);
        newFile.setEnabled(false);
        if (tp!=null) {
          DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode)tp.getLastPathComponent();
          File f = (File)dmtn.getUserObject();
          if (f.isDirectory()) {
            newDir.setEnabled(true);
            newFile.setEnabled(true);
      void addChildren(DefaultMutableTreeNode parent) {
        File parentFile = (File)parent.getUserObject();
        File[] children = parentFile.listFiles();
        for (int i=0; i<children.length; i++) {
          DefaultMutableTreeNode child = new DefaultMutableTreeNode(children);
    parent.add(child);
    if (children[i].isDirectory()) addChildren(child);
    public static void main(String[] args) { new Test(); }

  • Open a file dialog box using java

    Duncan & Frank or anyone
    Can you please tell, or give me a link, which explains how to open a file dialog box using java, and not webutil.
    I'm trying to read a file on the desktop and update a database table.
    Thanks

    See Open File Dialog on the WEB... If you can get me the full version numbers I can tell you your supported position.
    Regards
    Grant

  • Open a PDF file in linux using java

    Hi..
    How can I open a PDF file in linux using java.
    I am able to open PDF in windows and mac using this code
    in Windows
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);
    in mac
    Runtime.getRuntime().exec("open " + path_of_PDF);
    But nothing is working with linux.
    Please help
    Thanks

    One thread is enough:
    http://forum.java.sun.com/thread.jspa?threadID=5267458

  • Open PDF file in linux using java

    Hi..
    How can I open a PDF file in linux using java.
    I am able to open PDF in windows and mac using this code
    in Windows
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);
    in mac
    Runtime.getRuntime().exec("open " + path_of_PDF);
    But nothing is working with linux.
    Please help
    Thanks

    appi wrote:
    Hi.. I found the JDIC binary files. There are different binaries for all the plateform. Is there any solution which is independent of plateform.Yes, and we already told you: Use JDK6, which has those libraries built into the standard class library.
    How can I use these binaries in my existing project. does it work, If I place them at same place where other .class files are kept.Read the documentation of the JDIC project. I'm sure they answer this question in their FAQ.

  • File to JDBC using JAVA Mapping

    Hello,
      Can u explain me about the above scenario of File to JDBC using JAVA Mapping.
       Iam new to XI explain above in detail.
    *Points will be Rewarded*
    Thanks&Regards,
    RavichandKone.

    HI,
    If your mapping is one to one then dont go for java mapping use graphical mapping.
    /people/sap.user72/blog/2005/06/01/file-to-jdbc-adapter-using-sap-xi-30 --> for jdbc receiver: file -JDBC
    Here are the link which will help you in writing the stored procedure:
    Receiver JDBC scenario MS access - /people/sameer.shadab/blog/2005/10/24/connecting-to-ms-access-using-receiver-jdbc-adapter-without-dsn
    Stored Procedures-
    /people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
    http://www.ics.com/support/docs/dx/1.5/tut6.html
    /people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi
    http://www.ics.com/support/docs/dx/1.5/tut6.html
    http://java.sun.com/docs/books/tutorial/jdbc/basics/sql.html
    http://www.sqlteam.com/article/stored-procedures-an-overview
    thnx
    Chirag Gohil

  • Convert XML file into DTD using Java

    Hi All,
    I want to do convert the xml file into DTD using Java.
    I read the DOM package but didnt get clear idea.
    Anyone of you have an idea please share the coding with me.
    Any suggestions greatly appreciated.
    Thanks
    Veera

    Hi All,
    I want to do convert the xml file into DTD using Java.
    I read the DOM package but didnt get clear idea.
    Anyone of you have an idea please share the coding with me.
    Any suggestions greatly appreciated.
    Thanks
    Veera

  • How to view file from vss using java Commandline

    Hi To ALL,
    I wanted to view a file from vss through java code.
    By using the folowing code,i could able to get vss file in to local folder.
    Runtime.getRuntime().exec
    ("cmd /c ss Get $/Mywork/Myfile.java -GLC:/New");
    But i wanted to view file from vss using java code.
    any one please help me..
    Thanks in advance.........

    As always, Google is your friend.
    Follow the bouncing link.
    http://www.google.com/search?hl=en&q=VisualSourceSafe+%2B+Java+API
    PS.

  • How to extract .sit files(in MAC)  using java program

    Hi,
    please help me , i want to simple program for
    " how to extract .sit files(in MAC) using java program"
    that sit files same as zip files in windows..[                                                                                                                                                                                                                                                                                                                                   

    Thanks for reply...
    but i search in the google about this topic...there is no results will appear..
    the problem is "i have to run program in the MacOS like extract all the
    .sit(StuffIt) extension files. These sit files same as zip files in the windows... we have one tool called StuffIt Expander but it is 3rd party tool. but here requirement is i have to write my own program to extract all the files same as zip file program...
    please do the needful..i am waiting for ur reply,,,

  • How does one know whether or not they use "Java applets"?

    The support doc for the recent Java update (Update 8, for Snow Leopard), entitled "About Java for Mac OS X 10.6 Update 8," advises the following:
    If you do not use Java applets, it is recommended that you disable the Java web plug-in in your web browser.
    How does one know whether or not they use "Java applets"?
    Thanks.
    URL:  http://support.apple.com/kb/HT5243

    K.S. wrote:
    dymar wrote:
    Also, how would I know that a missing applet was causing some feature(s) not to work in a situation where no error mesage was returned?
    Sometimes you have to dig to find out: http://earthnow.usgs.gov/earthnow_app.html
    doesn't tell you directly, but it is mentioned in the FAQ that Java is required. If the content is appropriate, you can always ask here.
    Thanks.  According to that webpage, my "Java is out of date."  When an error message like that is returned, I guess it's clear that "it's a Java problem."  Presumably, one would then just go to java.com and download the applet if he/she wanted to view the webpage.
    I was wondering more about situation when unexplained problems that involved missing Java applets weren't noted in error messages.
    But maybe I'm worrying about something that doesn't really need to be worried about.

  • Is It Possible to store an entire  file in database using java?

    Hi All,
    I am new to Programming. please help he out Is It Possible to store an entire file in database using java? is possible, can u tell me the way to make this success? Thank you in advance.

    Thanks PhHein
    i got that application. i stored one file in db, and i displayed that in browser. thank u very much.

  • Unable to locate existing  file from unix using java program

    Hi
    I have created a file in unix using java program, file.createNewFile();
    And when i try to search for the same file using file.exists() it is returning false. Paths are correct. Can anybody help me out.
    Thanks & Regards,
    Prasanth

    In Linux FC5 using JDK1.6, this code         File temp = new File(System.getProperty("user.home") + "/abcdefghijklmn");
            System.out.println(temp.createNewFile());prints 'true' and the file is created with length zero.

  • How to convert xml file to xsl using java

    Hi all,
    I have an XML file with which i need to convert(transform) it to an xsl file using java.
    I am new to converting xml file to xslt.Please send me if u have code .
    Thanks in advance
    regards
    Ram

    You seem to be asking the wrong question. An XSL file can be used to transform an XML file, but transforming an XML into an XSL does not make sense. The API for running XSL transforms on the Java platform is described here:
    http://java.sun.com/javase/6/docs/api/javax/xml/transform/package-summary.html

Maybe you are looking for

  • Adobe Media Encoder Export Settings Window Dimensions Problem

    Any help on this would be appreciated: I'm on a macbook pro, osx 10.6, using CS4 Web Premium. I used to have an external monitor hooked up which had much higher resolution, so when using Adobe Media Encoder I'd click the Settings button on a video to

  • Re-using a clip

    Can anyone help here? I am trying to overlay clips using Slick 4 Mattastic.I want to use different parts of clips as the overlay at different points. After using part of a clip for this I cannot reuse a different part of the clip further on over the

  • How do I get rid of the interactive help?

    there is an interactive help thing on my computer.  Saying everything that I do and type etc. How do I get rid of it?!

  • When I try to export an InDesign document I can't choose any export options (epub, ea). I use InDesign CC2014.

    When I try to export an InDesign document I can't choose any export options (epub, ea). I use InDesign CC2014. See below my screendump and the missing exprt option field

  • Best back up scenario?

    Hi. I've got an 8-core 3.2ghz Mac Pro, used mainly for Protools, digital audio. All four drive bays are loaded with 1.5 TB drives in each. There is a system drive of course, and Protools audio drive, a virtual instrument drive, and a SAMPLE/loop/vide