Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Equivalent Java syntax from MatLab .m-file (read binary file)

807580Feb 3 2010 — edited Feb 12 2010
Hi, I have this Matlab code that will read a certain binary file format:
%File
f=fopen(a.file,'r','b');
%Header
a.id=char(fread(f,5,'uint8'))';
if ~strcmp(a.id,['ATSF' char(0)]), %ATFS
    a=[a.file ', unknown ats header:' a.id];
    fclose(f);
    return;
end
a.header=fread(f,1,'uint16');
a.channels=fread(f,1,'uint8');
a.blocks=fread(f,1,'uint32');
a.blocklength=fread(f,1,'uint16');
What I want is to do the same operation -- but in Java. It seems to me that data types uint8, uint16, and unit32 is more or less the same as the data types 'byte', 'short' and 'int' in Java. However, by using RandomAccessFile for data input I am only allowed to use 'byte' data type. Any ideas how to move on from here?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 12 2010
Added on Feb 3 2010
26 comments
379 views