Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8569
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.glorb.com!postnews.google.com!c1g2000yql.googlegroups.com!not-for-mail |
|---|---|
| From | bob <bob@coolgroups.com> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: DataInputStream |
| Date | Wed, 5 Oct 2011 07:12:57 -0700 (PDT) |
| Organization | http://groups.google.com |
| Lines | 44 |
| Message-ID | <59d03b15-34ac-4ec9-9b49-33f325f2e46a@c1g2000yql.googlegroups.com> (permalink) |
| References | <1418dd7f-d5d1-4a2c-b77b-87666f6a9591@k15g2000yqd.googlegroups.com> <9f2a8cFh1nU1@mid.individual.net> <6cf66421-77a9-4088-b810-3bcc958cc8ca@i28g2000yqn.googlegroups.com> <slrnj8o4bu.6gl.avl@gamma.logic.tuwien.ac.at> |
| NNTP-Posting-Host | 99.152.153.161 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | posting.google.com 1317823977 20917 127.0.0.1 (5 Oct 2011 14:12:57 GMT) |
| X-Complaints-To | groups-abuse@google.com |
| NNTP-Posting-Date | Wed, 5 Oct 2011 14:12:57 +0000 (UTC) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | c1g2000yql.googlegroups.com; posting-host=99.152.153.161; posting-account=v1lx5wkAAAALWYfGBkwkMb2guPF9cW2u |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| X-Google-Header-Order | HUALESNKRC |
| X-HTTP-UserAgent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1,gzip(gfe) |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8569 |
Show key headers only | View raw
Yes, I'm aware. I already had to change the endian-ness when the data
was written. Thanks.
On Oct 5, 3:12 am, Andreas Leitgeb <a...@gamma.logic.tuwien.ac.at>
wrote:
> bob <b...@coolgroups.com> wrote:
> > float[] getVertices3(String filename) {
> > try {
> > AssetManager am = this.getResources().getAssets();
> > InputStream is = am.open(filename);
> > DataInputStream dis = new DataInputStream(is);
> > int numfloats=dis.readInt();
> > float[] floatArray = new float[numfloats];
> > for (int ctr = 0; ctr < floatArray.length; ctr++) {
> > floatArray[ctr] = dis.readFloat();
> > }
> > return floatArray;
>
> Are you aware, that the DataInputStream expects a particular *binary*
> format of data coming from the stream?
>
> If the data stored in the file that you use still contains the same
> textual representation as for your previous questions, then
> DataInputStream won't be able to read it properly.
>
> You might create a separate converter utility, that reads in your
> textfile (with StreamTokenizer), then creates a binary file (writing
> out size and the individual floats through a DataOutputStream.
> That may seem roundabout, but is just right, if you *casually* need
> to hand-edit the text-file, but want speed-improved reading into your
> main application.
>
> Another option could be reading the float[] as a single object from
> an ObjectInputStream. Again. the data for that must have been created
> before by writing such an array to an ObjectOutputStream.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
DataInputStream bob <bob@coolgroups.com> - 2011-10-04 22:34 -0700
Re: DataInputStream Robert Klemme <shortcutter@googlemail.com> - 2011-10-05 08:02 +0200
Re: DataInputStream bob <bob@coolgroups.com> - 2011-10-04 23:17 -0700
Re: DataInputStream Robert Klemme <shortcutter@googlemail.com> - 2011-10-05 00:07 -0700
Re: DataInputStream bob <bob@coolgroups.com> - 2011-10-05 07:17 -0700
Re: DataInputStream markspace <-@.> - 2011-10-05 08:27 -0700
Re: DataInputStream Patricia Shanahan <pats@acm.org> - 2011-10-05 08:38 -0700
Re: DataInputStream Robert Klemme <shortcutter@googlemail.com> - 2011-10-05 08:58 -0700
Re: DataInputStream Lew <lewbloch@gmail.com> - 2011-10-05 14:52 -0700
Re: DataInputStream Patricia Shanahan <pats@acm.org> - 2011-10-05 15:15 -0700
Re: DataInputStream Robert Klemme <shortcutter@googlemail.com> - 2011-10-06 00:11 -0700
Re: DataInputStream Lew <lewbloch@gmail.com> - 2011-10-06 07:08 -0700
Re: DataInputStream Patricia Shanahan <pats@acm.org> - 2011-10-06 07:49 -0700
Re: DataInputStream Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-05 21:16 -0400
Re: DataInputStream Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-10-05 08:12 +0000
Re: DataInputStream bob <bob@coolgroups.com> - 2011-10-05 07:12 -0700
Re: DataInputStream Roedy Green <see_website@mindprod.com.invalid> - 2011-10-06 02:48 -0700
csiph-web