Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #27925

Re: RandomAccessFile and java.nio.*

From markspace <markspace@nospam.nospam>
Newsgroups comp.lang.java.programmer
Subject Re: RandomAccessFile and java.nio.*
Date 2014-03-31 15:27 -0700
Organization A noiseless patient Spider
Message-ID <lhcq4h$ikc$1@dont-email.me> (permalink)
References <slrnljh5m4.rhr.avl@login.logic.tuwien.ac.at> <lhakd2$joq$1@dont-email.me> <lham0i$sns$1@dont-email.me> <slrnljjc61.rhr.avl@login.logic.tuwien.ac.at>

Show all headers | View raw


On 3/31/2014 11:15 AM, Andreas Leitgeb wrote:

> It's still good to know, that I'm not re-inventing the wheel, when
> I roll my own for those needs.

I took a quick look at RandomAccessFile, and it seems to use a lot of 
native methods.  I would guess that porting it to the NIO FileChannels 
was more work than Sun/Oracle wanted to get into.

That said, a drop-in replacement would be nice.  Factor out an interface 
RandomAccessIO, make RandomAccessFile extend that interface, and then 
add a new class RandomAccessChannel that extends RandomAccessIO and 
wraps a FileChannel.  That I think would be my suggestion, if I were 
going to make one.

As it is, you're probably OK by re-inventing the wheel here, I don't see 
any other way.  RandomAccessFile is not final, you could extend it if 
you absolutely needed a drop-in replacement, but that seems like a very 
difficult solution given the way it's implemented.  Rolling your own 
from scratch is probably better.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

RandomAccessFile and java.nio.* Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-03-30 22:12 +0000
  Re: RandomAccessFile and java.nio.* Wayne <nospam@all.invalid> - 2014-03-30 22:24 -0400
    Re: RandomAccessFile and java.nio.* Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-03-31 17:54 +0000
  Re: RandomAccessFile and java.nio.* Jeff Higgins <jeff@invalid.invalid> - 2014-03-30 22:35 -0400
    Re: RandomAccessFile and java.nio.* markspace <markspace@nospam.nospam> - 2014-03-30 20:04 -0700
      Re: RandomAccessFile and java.nio.* Jeff Higgins <jeff@invalid.invalid> - 2014-03-31 02:09 -0400
        Re: RandomAccessFile and java.nio.* markspace <markspace@nospam.nospam> - 2014-03-31 00:02 -0700
          Re: RandomAccessFile and java.nio.* Jeff Higgins <jeff@invalid.invalid> - 2014-03-31 08:03 -0400
      Re: RandomAccessFile and java.nio.* Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-03-31 18:15 +0000
        Re: RandomAccessFile and java.nio.* Jeff Higgins <jeff@invalid.invalid> - 2014-03-31 14:38 -0400
          Re: RandomAccessFile and java.nio.* Jeff Higgins <jeff@invalid.invalid> - 2014-03-31 17:11 -0400
          Re: RandomAccessFile and java.nio.* Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-04-01 13:43 +0000
        Re: RandomAccessFile and java.nio.* markspace <markspace@nospam.nospam> - 2014-03-31 15:27 -0700
          Re: RandomAccessFile and java.nio.* Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-04-01 13:29 +0000
        Re: RandomAccessFile and java.nio.* markspace <markspace@nospam.nospam> - 2014-03-31 17:36 -0700
          Re: RandomAccessFile and java.nio.* Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-04-01 13:18 +0000

csiph-web