Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > file i/o with byte values

Reply
Thread Tools

file i/o with byte values

 
 
kvnsmnsn@hotmail.com
Guest
Posts: n/a
 
      06-17-2005
The only way I know how to do I/O with a file is with the
<println> and <readLine> methods. But now I'm getting ready to do a
project that will essentially have me writing binary to a file and
then reading binary from that file. The values written to and read
from will be <byte> values. Does anyone out there know how to just
plain write an individual <byte> to a file and read an individual
<byte> from one? Thanks in advance for any information you can give
me.

---Kevin Simonson

"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_

 
Reply With Quote
 
 
 
 
Lee Fesperman
Guest
Posts: n/a
 
      06-17-2005
wrote:
>
> The only way I know how to do I/O with a file is with the
> <println> and <readLine> methods. But now I'm getting ready to do a
> project that will essentially have me writing binary to a file and
> then reading binary from that file. The values written to and read
> from will be <byte> values. Does anyone out there know how to just
> plain write an individual <byte> to a file and read an individual
> <byte> from one? Thanks in advance for any information you can give
> me.


Do a little reading in the java.io package. InputStream and OutputStream are the basic
classes for accessing byte values in a stream. They provide read() and write() for
bytes. For files, you'd use FileInputStream and FileOutputStream. For random access, see
RandomAccessFile.

--
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
================================================== ============
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
 
Reply With Quote
 
 
 
 
kvnsmnsn@hotmail.com
Guest
Posts: n/a
 
      06-17-2005
Lee Fesperman posted:

=> The only way I know how to do I/O with a file is with the
=> <println> and <readLine> methods. But now I'm getting ready to do a
=> project that will essentially have me writing binary to a file and
=> then reading binary from that file. The values written to and read
=> from will be <byte> values. Does anyone out there know how to just
=> plain write an individual <byte> to a file and read an individual
=> <byte> from one? Thanks in advance for any information you can give
=> me.
=
=Do a little reading in the java.io package. InputStream and
=OutputStream are the basic classes for accessing byte values in a
=stream. They provide read() and write() for bytes. For files, you'd
=use FileInputStream and FileOutputStream. For random access, see
=RandomAccessFile.

Thanks! <FileInputStream> and <FileOutputStream> did exactly
what I needed.

---Kevin Simonson

"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
read text file byte by byte daved170 Python 30 12-16-2009 09:54 PM
byte[] > string > byte[] problem Peter Java 3 08-05-2004 10:55 AM
connection 1: transfer chunk 1 (byte 0 to byte 1024) Jean-Daniel Gamache Java 0 07-14-2004 03:57 AM
Single byte addressable, multiple byte readout. Andreas VHDL 1 05-04-2004 01:49 PM
Appending byte[] to another byte[] array Bharat Bhushan Java 15 08-05-2003 07:52 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57