Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

java read binary file created with VB6 put

Avatar of marioraposo
marioraposo asked on
Editors IDEs
9 Comments1 Solution473 ViewsLast Modified:
I have a file that i created using VB6 put

Type REG
  R1         As Integer
  R2         As Double
  End Type
Global REG1       As REG

and

Close
Open "c:\abc" For Random As #1 Len = Len(REG1)
REG1.R1 = -1234
REG1.R2 = -123.456
Put #1, 1, REG1
Close


now I want to read the same file with java using this code

        try {
            RandomAccessFile raf = new RandomAccessFile("c:/abc", "rw");
            short r1 = raf.readShort();
            double r2 = raf.readDouble();
            System.out.println(r1);
            System.out.println(r2);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

and i get the following result for r1 and r2
12027
6.31920603993197E268



I also tryed with with DataInputStream


 try {
            DataInputStream din = new DataInputStream(new FileInputStream("c:/abc"));
            short r1 = din.readShort();
            double r2 = din.readDouble();
            System.out.println(r1);
            System.out.println(r2);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }


but I got the same result
12027
6.31920603993197E268


how can I do this ?
ASKER CERTIFIED SOLUTION
Avatar of marioraposo
marioraposo

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answers