Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8593
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: DataInputStream |
| Date | 2011-10-06 02:48 -0700 |
| Organization | Canadian Mind Products |
| Message-ID | <6vtq8799uup4maagr4e2fj6na1hcg37dbl@4ax.com> (permalink) |
| References | <1418dd7f-d5d1-4a2c-b77b-87666f6a9591@k15g2000yqd.googlegroups.com> |
On Tue, 4 Oct 2011 22:34:56 -0700 (PDT), bob <bob@coolgroups.com> wrote, quoted or indirectly quoted someone who said : >I want to use DataInputStream to read into a float[]. Anyone know how >to do this? In Java, with DataInputStream you have to think in terms of reading primitives, not records as you would in C++ or COBOL. You would read a count followed by n floats, one field at a time. Ask http://mindprod.com/jgloss/fileio.html to generate you the code. You can logically read and write entire objects including arrays with dependent contents using serialization. See http://mindprod.com/jgloss/serialization.html again http://mindprod.com/jgloss/fileio.html will generate you sample code. Part of the reason is Java as WORA. The I/O has to work whether the machine is internally in big or little ended. the run time has to convert on a field by field basis. Java can't treat objects/records as just a blob of bytes the way earlier machine-dependent languages can. It is a lot easier to let java determine the exact binary layout of files rather that trying to read some bizarre format created elsewhere. Then you have to read byte by byte with an InputStream. -- Roedy Green Canadian Mind Products http://mindprod.com It should not be considered an error when the user starts something already started or stops something already stopped. This applies to browsers, services, editors... It is inexcusable to punish the user by requiring some elaborate sequence to atone, e.g. open the task editor, find and kill some processes.
Back to comp.lang.java.programmer | Previous | Next — Previous 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