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


Groups > comp.lang.java.programmer > #22467 > unrolled thread

offsets in a FileChannel ...

Started byqwertmonkey@syberianoutpost.ru
First post2013-02-23 14:54 +0000
Last post2013-02-23 21:22 +0100
Articles 2 — 2 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  offsets in a FileChannel ... qwertmonkey@syberianoutpost.ru - 2013-02-23 14:54 +0000
    Re: offsets in a FileChannel ... Robert Klemme <shortcutter@googlemail.com> - 2013-02-23 21:22 +0100

#22467 — offsets in a FileChannel ...

Fromqwertmonkey@syberianoutpost.ru
Date2013-02-23 14:54 +0000
Subjectoffsets in a FileChannel ...
Message-ID<kgal78$blo$1@speranza.aioe.org>
> ... You would have to create more complex code if you want to align char
position and byte position. 
~ 
 but then why do they have a:
~ 
 docs/api/java/nio/channels/FileChannel.html#position()
~ 
 in the API? How/What is it used for?
~ 
 If you read the FileChannel.position() as you read off the chars from the
CharBuffer you always get 0 (as if the offset pointer in the underlying
FileChannel would not advance)
~ 
 I am using:
~ 
$ java -version
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) Client VM (build 23.6-b04, mixed mode)
~ 
 lbrtchx

[toc] | [next] | [standalone]


#22473

FromRobert Klemme <shortcutter@googlemail.com>
Date2013-02-23 21:22 +0100
Message-ID<aosmp8FnroU1@mid.individual.net>
In reply to#22467
On 23.02.2013 15:54, qwertmonkey@syberianoutpost.ru wrote:
>> ... You would have to create more complex code if you want to align char
> position and byte position.
> ~
>   but then why do they have a:
> ~
>   docs/api/java/nio/channels/FileChannel.html#position()
> ~
>   in the API? How/What is it used for?

http://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileChannel.html#position()

> ~
>   If you read the FileChannel.position() as you read off the chars from the
> CharBuffer you always get 0 (as if the offset pointer in the underlying
> FileChannel would not advance)

Probably because you are not reading through the channel but mapping the 
file into memory.

Please stop ripping your posting threads apart.  Thank you.

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web