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


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

Re: RandomAccessFile and java.nio.*

From Jeff Higgins <jeff@invalid.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: RandomAccessFile and java.nio.*
Date 2014-03-31 14:38 -0400
Organization A noiseless patient Spider
Message-ID <lhccs2$43l$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 03/31/2014 02:15 PM, Andreas Leitgeb wrote:
> Thanks Jeff & Mark for this subthread.
>
> It's not very likely that I'll create a JEP(roposal) for this ;-)

Durn. I was hoping to see the results of a sanity check.

> BufferedReader has the same problem as Scanner (as suggested by Wayne):
> it doesn't give me a clue as to the exact file position corresponding
> to the point where the line (and nothing beyond) has been read.
> That's not really surprising as such, given the stack of Reader/Stream-
> wrappers involved, but RandomAccessFile *was* able to give me that
> information.
>
> What I really need is saving a particular position (like after having
> read first line), in order to be able to jump back to that position at
> a later time and (physically) re-read the second line (data might have
> changed by the time I re-read it, but the position will be same. Yeah,
> odd).
>
> (This is just for files, of course.  There is no seek'ing back on pipes
> and sockets, of course, but I'd still like to use the same readLine()/
> nextLine()-API for all channels regardless if I'll later need to seek(),
> or not.)

It's not real clear to me what you want to accomplish.
It you read a line such as:
First Name ___________________
do you hope to replace it with:
First Name Andreas

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

I'm hoping for a real world excellent example of a
Spliterator implementation, please keep us updated.



> markspace <markspace@nospam.nospam> wrote:
>> On 3/30/2014 7:35 PM, Jeff Higgins wrote:
>>> LineNumberReader takes a Reader
>>> Channels.newReader takes a ReadableByteChannel (FileChannel)
>> Once you have a Reader, using a BufferReader would probably be more
>> clear to a maintainer, assuming line number counting isn't required.
>>
>> But I agree with Andreas that RandomAccessFile seems to have been left
>> an orphan when the NIO stuff came out.  I can't figure out a way to get
>> there.
>>

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