• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to write to a particular location in a file?  RSS feed

 
Sindhur Satrasala
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
Is there anyway I can write to a particular part of a file. Like for example. I have an array of bytes that I want to write to a file at a particular offset into the file. Are there functions like fseek and lseek in Java.
Thank you
Regards,
Sindhur.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sindhur,
Does "java.io.RandomAccessFile" not help you?
http://java.sun.com/j2se/1.4.1/docs/api/java/io/RandomAccessFile.html
Good Luck,
Avi.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using JDK 1.4 (and why not?) you can also use a FileChannel, which has a similar API but is often much faster than RandomAccessFile.
 
Sindhur Satrasala
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, RandomAccessFile solved my problem
 
wowo wang
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RandomAccessFile is so slowly...
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!