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


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

offsets in a FileChannel ...

Path csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From qwertmonkey@syberianoutpost.ru
Newsgroups comp.lang.java.programmer
Subject offsets in a FileChannel ...
Date Sat, 23 Feb 2013 14:11:49 +0000 (UTC)
Organization Aioe.org NNTP Server
Lines 29
Message-ID <kgain5$4pl$1@speranza.aioe.org> (permalink)
NNTP-Posting-Host jcJFTAhAdFLWfAXONlzC5w.user.speranza.aioe.org
X-Complaints-To abuse@aioe.org
X-Notice Filtered by postfilter v. 0.8.2
X-Newsreader NetComponents
Xref csiph.com comp.lang.java.programmer:22465

Show key headers only | View raw


 What is missing in this code snippet to get the offsets in the underlying
FileChannel on which the MappedByteBuffer and then the CharBuffer are built?
~ 
 CharBuffer.position() gives you the position alright, but how about wanting
to get the actual offset of certain characters in the actual data feed exposed
through the FileInputStream?
~ 
     char c;
     long lPsx;
     FIS = new FileInputStream(IFl);
     FileChannel FlChnl = FIS.getChannel();
     MappedByteBuffer MptbChnlBfr = FlChnl.map(FileChannel.MapMode.READ_ONLY,
0, FlChnl.size());
     CharBuffer cBfrUTF8 = ChrStDkdr.decode(MptbChnlBfr);
// __ 
     while(cBfrUTF8.hasRemaining()){
      c = cBfrUTF8.get();
      lPsx = cBfrUTF8.position();
      System.err.println("// __ |" + lPsx + "|" + c + "|" + (int)c + "|");
     }
// __ 
     FlChnl.close();
     FIS.close();
~ 
 Or do you know of any other way to basically do the same thing?
~ 
 thanks,
 lbrtchx
 comp.lang.java.programmer:offsets in a FileChannel ...

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


Thread

offsets in a FileChannel ... qwertmonkey@syberianoutpost.ru - 2013-02-23 14:11 +0000
  Re: offsets in a FileChannel ... Robert Klemme <shortcutter@googlemail.com> - 2013-02-23 15:39 +0100
    Re: offsets in a FileChannel ... Roedy Green <see_website@mindprod.com.invalid> - 2013-02-25 04:09 -0800
      Re: offsets in a FileChannel ... Robert Klemme <shortcutter@googlemail.com> - 2013-02-25 21:50 +0100
        Re: offsets in a FileChannel ... Roedy Green <see_website@mindprod.com.invalid> - 2013-02-26 08:05 -0800

csiph-web