Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Jan Burse Newsgroups: comp.lang.java.programmer Subject: Re: Piggypack Encoding/Decoding on RandomAccessFile Date: Thu, 03 Nov 2011 23:24:09 +0100 Organization: albasani.net Lines: 41 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net irzwGQaHe20BWmOo9GgCSxQ5WQXv1Zk6mJ8CHdxuv4NKKZuMbuN0aQ/2JWSEiNV9GK92zriAYStZPUwNovrviQ== NNTP-Posting-Date: Thu, 3 Nov 2011 22:24:13 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="T3hR3skmEjZQWBZnOw4/j0SLAPgYirTep1fKWzZ2NGliiZd6pK96lxMZySn+W4D4kZVTwQjgVjkQD2HjMJO5uiWOEiqLC2VqcXafyZabKFhzxQx17SV+NsqIygmQZ8ki"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20110928 Firefox/7.0.1 SeaMonkey/2.4.1 In-Reply-To: Cancel-Lock: sha1:v9TOegp+sW4T/YcaSO+3Bzb4Jf4= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9474 Jan Burse schrieb: > Should I mingle with file descriptor, and get > associated input and output streams, and then > move forward? BTW: The file descriptor route works as follows: RandomAccessFile raf = new RandomAccessFile(..., "r"); FileInputStream fi = new FileInputStream(raf.getFD()); ... change file position ... ... piggypack a InputStreamReader ... ... change file position ... ... piggypack another InputStreamReader ... fi.close(); raf.close(); Works also for FileOutputStream. But I am not sure whether it is the prefered route... Also since javadoc for InputStreamReader says: "To enable the efficient conversion of bytes to characters, more bytes may be read ahead from the underlying stream than are necessary to satisfy the current read operation." Reading the file position after some read from InputStreamReader will probably not give a reliable position. But advantage over a normal InputStreamReader, which has only a skip(), would be for example that a rewind() can be implemented via a seek(0). Bye