Re: Java I/O Seeking



david.goodyear@xxxxxxxxx wrote:

I'm used to using streams in C++ where you can seek negatively, in java however it appears you can only seek positively. Does this mean a negative seek can only be achieved using a reset() and seek(with a positive argument), to have the effect of a negative seek. (Isn't that very in-efficient with buffers?)

InputStream doesn't have seek. It does have skip. Most streams are not random access. Most uses of stream-like objects do not require random access behaviour. So it doesn't make a great deal of sense to have a seek method.


What you probably want is RandomAccessFile.

Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
.



Relevant Pages

  • Re: is Random Access File really "random access"?
    ... underlying OS provides random access files and the Java implementation didn't ... I /suspect/ that what they mean is that random access and buffering are largely ...
    (comp.lang.java.programmer)
  • Re: how to write in a jar file
    ... The only way to do that is to rewrite the ... entire jar/zip file. ... Java does not offer ... any form of 'random access' to compressed ...
    (comp.lang.java.programmer)
  • Re: quick ZipFile question
    ... >Constructing a java.io.File object does not create a file. ... >It merely represents a file and its attributes on the local filesystem. ... random access. ... Java programming tips: http://jiu.sourceforge.net/javatips.html ...
    (comp.lang.java.programmer)
  • Re: quick ZipFile question
    ... >Constructing a java.io.File object does not create a file. ... >It merely represents a file and its attributes on the local filesystem. ... random access. ... Java programming tips: http://jiu.sourceforge.net/javatips.html ...
    (comp.lang.java.help)
  • Re: "event"-like thread synchronization object?
    ... I don't know what you mean by "reset automatically when a thread is ... state when that one thread is released (if no threads are waiting at the ... Lock lock = new ReentrantLock; ... in Java, the most effective way to do it is to use Java idioms. ...
    (comp.lang.java.programmer)