Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Stanimir Stamenkov Newsgroups: comp.lang.java.programmer Subject: Re: Piggypack Encoding/Decoding on RandomAccessFile Date: Sat, 05 Nov 2011 16:51:45 +0200 Organization: A noiseless patient Spider Lines: 38 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 5 Nov 2011 14:51:44 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="JHWHUqw5GqhE36YBoJ2mhw"; logging-data="11412"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191uov+Wjg4oi9HwciL85MB" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111012 Firefox/8.0 SeaMonkey/2.5 In-Reply-To: X-Face: "@)%Vlap6d%OVYDS}B4YUWE@yUy+^!w/+.q.,c5kjI#+uG?kYP&r/pTjNWgo:g[A,O=AL3/ j&4Le2cau$ encoding/deconding on a RandomAccessFile: > > http://download.oracle.com/javase/7/docs/api/java/io/RandomAccessFile.html > > Should I mingle with file descriptor, and get > associated input and output streams, and then > move forward? I think it is o.k. to use the FileDescriptor obtained from a RandomAccessFile to create a FileInputStream if you need to read the contents of the file through InputStream interface further. One could also obtain InputStream to the RandomAccessFile using its FileChannel: import java.io.InputStream; import java.io.RandomAccessFile; import java.nio.channels.Channels; RandomAccessFile raf; ... InputStream in = Channels.newInputStream(raf.getChannel()); java.nio.channels.Channels also provide: import java.io.Reader; Reader reader = Channels.newReader(raf.getChannel(), "UTF-8"); -- Stanimir