🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #18528

FileInputStream: How do I read in a 2D array of shorts from a file?

#18528
From: Shane Warren
Date: Fri, 05 Jun 1998 00:00
29 lines
1310 bytes
I'm having problems reading in a two-dimensional array of shorts from
a file.  The file contains an array written out using C++ that looks
like:
   
short array[100][256].  

I can't figure out how to make java read in this array.  I'm using
FileInputStreams read function that looks like:

read(byte[], int offset, int size).

I have an array in Java that is a short like:

short buffer = new short[100][256];

I'm trying to read in the file a row at a time into my short array
like this:

fin.read((byte[])buffer, 0, 512);

This should read in one row of data into my array, but Java won't let
me typecast my short array into a byte array.  

Anyone have any words of advice here, I'm sure I'm doing something
wrong, because I just started using Java and I'm not quite familiar
with it yet.  Thanks in advance for and help.

Shane Warren
Technical Details
Message-ID: <3577ded0.184517371@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,3bd33cfbcb3e6427,start
X-Google-Attributes: gidf74b3,public
From: swarren@bmi.net (Shane Warren)
Subject: FileInputStream: How do I read in a 2D array of shorts from a file?
Date: 1998/06/05
Message-ID: <3577ded0.184517371@forums.borland.com>
X-Deja-AN: 359937333
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.language