Your code is problematic: skipping the DataInputStream does not guarantee you that the underlying FileInputStream will be positioned at the desired byte offset when skipped. This is due to the buffering.
If you are to operate on your stream via a DataInputStream, use it exclusively: var dis = DataInputStream(file_stream) dis.skip(80); uint8 buffer[160]; size_t buffer_len; dis.read_all(buffer, out buffer_len); Alternatively, you should consider an HTTP range query, which will allow you to do the skip operation at zero-cost. It's a bit more boilerplate to set up the session and the HTTP message, but might be worth it if you skip numerous bytes. Le mer. 28 août 2019, à 04 h 54, Arvind Arvind Pro <arvind_...@arvind.pro> a écrit : > Hi > > I want to use Vala code to download only a portion in the latter part of a > file from internet- > > This is the code I have worked on so far- > > var file = File.new_for_uri (url); > var file_stream = file.read (); > var data_stream = new DataInputStream (file_stream); > data_stream.skip (offset); > singlelineofdata = file_stream.read ( offset, 80, 1); > > What I want to know is this- offset is the number of bytes within the > file, after which I want to download the remaining content. > Is the above code correct? Because skip should either mean that the > content being skipped has already being downloaded, whereas I wish to > download the portion after the offset. (A random number of bytes for this > example). If the above is not correct then what is the correct way of doing > this. > > > Yours sincerely, > Arvind. > _______________________________________________ > vala-list mailing list > vala-list@gnome.org > https://mail.gnome.org/mailman/listinfo/vala-list > -- Guillaume Poirier-Morency <guillaumepoiriermore...@gmail.com> Étudiant à la maîtrise en informatique à l'Université de Montréal Chercheur à l'Institut de recherche en immunologie et en cancérologie *Page Web:* arteymix.github.io *Clé PGP:* B1AD6EA5 <https://pgp.mit.edu/pks/lookup?op=vindex&search=0x1CCFC3A2B1AD6EA5> _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list