Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

file i/o with byte values

Thread view: 
kvnsmnsn@hotmail.com - 17 Jun 2005 01:53 GMT
    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_
Lee Fesperman - 17 Jun 2005 02:34 GMT
>      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
[quoted text clipped - 4 lines]
> <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.

Signature

Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS  (http://www.firstsql.com)

kvnsmnsn@hotmail.com - 17 Jun 2005 23:23 GMT
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_


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.