Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Piggypack Encoding/Decoding on RandomAccessFile Date: Thu, 3 Nov 2011 13:58:33 -0700 (PDT) Organization: http://groups.google.com Lines: 17 Message-ID: <8910467.293.1320353913956.JavaMail.geo-discussion-forums@prmv24> References: Reply-To: comp.lang.java.programmer@googlegroups.com NNTP-Posting-Host: 2620:0:1000:2404:224:d7ff:fe69:5838 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1320354851 10341 127.0.0.1 (3 Nov 2011 21:14:11 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 3 Nov 2011 21:14:11 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2620:0:1000:2404:224:d7ff:fe69:5838; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9471 On Thursday, November 3, 2011 12:50:45 PM UTC-7, Jan Burse wrote: > Joshua Cranmer schrieb: > > The "standard way" (at least, all of the use cases I've ever had for > > RandomAccessFile) effectively uses the methods that are associated with > > java.io.DataInput to read data: read(byte[]), and read*(). > > I would like to use an arbirary encoding/decoding on top of the > byte stream to get a character stream. But since RandomAccessFile > does not implement InputStream/OutputStream, I cannot create > a InputStreamReader/OutputStreamWrite on top. No, but you can use the 'DataInput' (and 'DataOutput') methods, as Joshua indicated. However, the notion of encoding / decoding from a random access file seems fraught with peril. You have to ensure that you start from a valid position in the file, not, for example, in the second byte of a three-byte character. -- Lew