Jay Orsaw wrote:they are serialized in Binary, and I tried to look up on how to serialize/deserialize in Binary, but didn't have much help...
Jay Orsaw wrote:
The error appears when reading the file... hmmm...
Jeff Verdegan wrote:
Jay Orsaw wrote:they are serialized in Binary, and I tried to look up on how to serialize/deserialize in Binary, but didn't have much help...
"Binary" is not one single format. Word files, Excel files, Java's .class files, .exe files--they're all binary and they're all very different. Java's serialization mechanism is also binary, but that doesn't mean it can read any of those other formats or whatever format your VB files use.
All "binary" really means in terms of file formats is "may contain bytes that don't translate into textual characters."
You have two basic approaches:
1) Search for a third-party Java library that knows how to read that VB6 format.
2) Find the specs for that format and write your own deserialization code.
Jeff Verdegan wrote:
Jay Orsaw wrote:
The error appears when reading the file... hmmm...
What file? Are you trying to read the VB6 file with Java's ObjectInputStream? You can't do that. That would only work if Java's serialization format was the same as that VB6 format, which is phenomenally unlikely. Just writing a Java class that's the structural equivalent of the VB6 class doesn't magically make Java able to understand the VB6 format.
Jay Orsaw wrote:That is what I'm asking.
2) Find the specs for that format and write your own deserialization code.
What did you mean by that? I thought you meant if I knew the code in the VB file, I would be able to do it.
How am I able to read a VB6 file? Is it possible? Nothing on google at all, this question itself is on Google's first page...
Paul Clapham wrote:
Jay Orsaw wrote:That is what I'm asking.
2) Find the specs for that format and write your own deserialization code.
What did you mean by that? I thought you meant if I knew the code in the VB file, I would be able to do it.
How am I able to read a VB6 file? Is it possible? Nothing on google at all, this question itself is on Google's first page...
There's no such thing as "a VB6 file". Or rather, VB code can write anything it likes into a file. So for example it might write a 32-character string followed by two integer values (at four bytes each). Or it might write a long integer value (eight bytes) followed by a single character followed by a short integer value (two bytes). The possibilities are endless. So what you have to do -- as already stated -- is to find out what is in that file. How it is structured. The format of the file, in other words. The answer is going to be something like one of the two examples I just mentioned, only probably more complicated than that.
If you don't have anybody to tell you what the format is then you're probably out of luck. Unless you have a copy of the code which produces the file, in which case you might have a chance at figuring it out.
Jay Orsaw wrote:thank you, as I have already mentioned I HAVE THE FILE, now what do I do with it? I have the format and I made it into a class but the problem is I cannot read it in with the objectinputsteam, as stated above I get an error. What should I do to read in the file since the OIS isn't working?
There are 3 TYPES each type has a set of objects like "String" for example. I set up the first TYPE as 1 class called planHead(Same as in the Vb code in the file..) But as you can see in the problem above I am stuck at reading in the file to try and deserialize it, so that's why I ask if there is a different way to read it in..?
Jay Orsaw wrote:
Jeff Verdegan wrote:
Jay Orsaw wrote:
The error appears when reading the file... hmmm...
What file? Are you trying to read the VB6 file with Java's ObjectInputStream? You can't do that. That would only work if Java's serialization format was the same as that VB6 format, which is phenomenally unlikely. Just writing a Java class that's the structural equivalent of the VB6 class doesn't magically make Java able to understand the VB6 format.
That is what I'm asking.
2) Find the specs for that format and write your own deserialization code.
What did you mean by that? I thought you meant if I knew the code in the VB file, I would be able to do it.
How am I able to read a VB6 file? Is it possible?
Paul Clapham wrote:
I guess this hasn't been explicitly stated, so let me start by pointing out that you can't use Java serialization, because that isn't how the file is formatted.
me wrote:Java's serialization mechanism is also binary, but that doesn't mean it can read any of those other formats or whatever format your VB files use.
me wrote:That would only work if Java's serialization format was the same as that VB6 format, which is phenomenally unlikely.
Jay Orsaw wrote:
thank you, as I have already mentioned I HAVE THE FILE, now what do I do with it?
I have the format and I made it into a class
Paul Clapham wrote:
Jay Orsaw wrote:thank you, as I have already mentioned I HAVE THE FILE, now what do I do with it? I have the format and I made it into a class but the problem is I cannot read it in with the objectinputsteam, as stated above I get an error. What should I do to read in the file since the OIS isn't working?
There are 3 TYPES each type has a set of objects like "String" for example. I set up the first TYPE as 1 class called planHead(Same as in the Vb code in the file..) But as you can see in the problem above I am stuck at reading in the file to try and deserialize it, so that's why I ask if there is a different way to read it in..?
I guess this hasn't been explicitly stated, so let me start by pointing out that you can't use Java serialization, because that isn't how the file is formatted.
But you have the specs about what is in the file (right? That was what you meant when you said you "have the format", was it?) so the next step is to write some Java code which reads the file. If the specs include binary data which corresponds to Java types then you could use a DataInputStream to read that data.
Jay Orsaw wrote:Thank you the DataInputStream worked, only issue is that when I use the VB "Single" with the Java "Float" I get a # like 2.40239E-41 when it should be 3.0.
If I read in 2 characters from the stream and then do the float I get 3.0, but when I try to do that with the next float which should be 4.0, I cannot, and I doubt that even makes sense to read in the 2 extra characters...
Everything else works fine except for this float... Even reading data after the misread floats, was successful. The joys of multiple languages... BOO!!! Java forever!
Paul Clapham wrote:What you are now doing is called "reverse engineering". A tedious technique but probably the only one available at this point in time.
You may find that looking at the hexadecimal representation of data in the file helps. For this you can use a tool called a "hex editor". You'll find plenty of them available on the internet.
Jay Orsaw wrote:it goes 2 Strings, 1 boolean, 2 floats, 2 ints, ETC. The fact I can read in the 2 strings, the 1 boolean, the 2 floats(wrong values) and then getting the CORRECT 2 int values next is weird.
Returns the float value corresponding to a given bit representation. The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "single format" bit layout.
Jay Orsaw wrote:I can read the other things in order no problem
this floating point # is giving me a random number...
There is nothing between the BOOLEAN and the FLOAT, but the only way to actually get 3.0 is by throwing out 2 characters,
I'm not sure how I'm "reverse engineering" since I have everything needed,
I just need Java to be able to work for it...
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:Just reading this topic, and I was wondering: have you by any chance VB6 around (or maybe even VB4.5)? Or do you know someone who does?
Then it would be a very easy job to read those files in uing VB and write them out as text (using the PRINT# statements).
You would need to know what's in those files, but if I understand correctly that's not the problem.
Greetz,
Piet
Jay Orsaw wrote:I just want to say you're a lifesaver, thanks a ton for this!
I wanted to know, what if we do run into a Byte issue?
From what I saw doing my own conversion the real issue was Floats and Doubles.
Is there any documentation you read up on to do this, or you just know a lot about binary, I'm interested to know more about it all, though if I looked into it, it might not be that difficult!
Tony Docherty wrote:Hi Antoine,
For your continued help on this difficult topic and for providing your library I've awarded you a cow.
Police line, do not cross. Well, this tiny ad can go through:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|