Re: EOF location?
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Mon, 29 May 2006 15:32:40 GMT
"Michael Mattias" <michael.mattias@xxxxxxx> wrote in message news:3gieg.714$VE1.70@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Bottom line is, on the MS-DOS and WIndows operating systems all files are
but a stream of bytes; there are no end-of-record markers, there is no
end-of-file marker; all characaters stored in the file are equally
considered valid 'data' characters.
To further support this view, in Java, the function[*] which is used to read a byte can return any value from -1 to 255. If you get values between 0 and 255, that means the function actually did manage to read a byte from the file, and it may very well be 0x1A (AKA CTRL-Z). If that function returns -1, that means that the end of the file has been reached.
A byte, as we all know, can have one of 256 possible values, but this read function may return one of 257 possible values. So a file could, for example, start with a 0x1A, and then have a 0x41 (the capital letter 'A'), and then just end right there and then, with no line feeds, carriage returns, or CTRL-Zs or anything else. In Java, you'd receive the decimal values 27, 33 and -1 to represent this stream of bytes of length 2.
- Oliver
[*] Actually, there's more than one way to read data from a file. The one I'm referring to here, for the curious, is java.io.FileInputStream.read().
.
- References:
- EOF location?
- From: HeyBub
- Re: EOF location?
- From: Pete Dashwood
- Re: EOF location?
- From: Rick Smith
- Re: EOF location?
- From: Pete Dashwood
- Re: EOF location?
- From: Rick Smith
- Re: EOF location?
- From: Pete Dashwood
- Re: EOF location?
- From: Roger While
- Re: EOF location?
- From: Michael Mattias
- EOF location?
- Prev by Date: Re: Is a career switch to the mainframe/cobol world responsible?
- Next by Date: Re: [OT] Back Again
- Previous by thread: Re: EOF location?
- Next by thread: Re: EOF location?
- Index(es):