troubleshooting Question

Reading a Binary / Structured / Formated File Using JAVA

Avatar of udanabanana
udanabananaFlag for Australia asked on
JavaProgramming Languages-Other
16 Comments1 Solution408 ViewsLast Modified:
Language: Java
OS: Windows XP
My Java knowledge: Learning/Low

I need to read a structured file(Hist.dat) which written using Visual Basic.
Visual Basic Structure is
        Type Histx
                Units(380) As Single ' Single is equal to float in java, 4 bytes
                Sell(380) As Single
                Cost(380) As Single
                Prom(380) As Integer ' Integer is equal to short in java, 2bytes
        End Type
so each record is (381 X 4) X 3 + 381 X 2 bytes , = 5334 bytes
it can be 100 000 records in a file. 5334 X 100 000 = 508.7 Mb

File Structure(a= first record, b= second record,  n= nth record)
Ua1....Ua381 Sa1......Sa381 Ca1....Ca381 Pa1.....Pa381 Ub1....Ub381 Sb1......Sb381 Cb1....Cb381 Pb1.....Pb381 ......................................Un1....Un381 Sn1......Sn381 Cn1....Cn381 Pn1.....Pn381

Ua1 = 4bytes representing first element of Unites in first record.
Pb381 = 2bytes repesenting last element of Prom in second record. and so on.
 You can download a sample Hist File from (25KB)

Keep in mind Hist.dat file can be 1Mb to 500 Mb.
Speed mabe a issue.
Is it possible to read a structured file written using VB by java? I assume it can be done.
I want to read this data from Hist.dat and write to comma seperated file as numbers. How can we do this? Whats the best way to read data from file? Please answer with a Full Working Example.
Post Notes: I need a realy realy smart programmer to Answer this question. I post this question earlier and I didnt get the desired answer. I spend more than 10 days googling a answer. So kind frustrated now.

Please Please Help, Udana

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 16 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 16 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004