troubleshooting Question

Reading a Binary / Structured / Formated File Using JAVA

Avatar of udanabanana
udanabananaFlag for Australia asked on
Programming Languages-OtherJava
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 http://www.postecsolutions.com.au/EE/HisD5.zip (25KB)

Attention.
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.
__________________________________________________________
QUESTION:
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

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 16 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros