are there lseek/seek, tell, etc. in Java?

Discussion in 'Java' started by Gordon Beaton, Apr 22, 2008.

  1. On Tue, 22 Apr 2008 08:13:36 -0400, RC wrote:
    > I want to do some lseek/seek (like C) first, then it "tell (like C)"
    > the position. Then I write in somewhere in myfile


    java.io.RandomAccessFile has what you're looking for.

    /gordon

    --
     
    Gordon Beaton, Apr 22, 2008
    #1
    1. Advertising

  2. Gordon Beaton

    RC Guest

    When I open a file by

    BufferedWriter bw =
    new BufferedWriter(new FileWriter(new File("myfile")));

    Where myfile is existed, I don't want to over write the
    file from top, I want to do some lseek/seek (like C) first,
    then it "tell (like C)" the position. Then I write in somewhere
    in myfile

    I only found append, and write methods in java.io.Writer class

    Thank you very much in advance!
     
    RC, Apr 22, 2008
    #2
    1. Advertising

  3. Gordon Beaton

    Roedy Green Guest

    On Tue, 22 Apr 2008 08:13:36 -0400, RC <>
    wrote, quoted or indirectly quoted someone who said :

    >I want to do some lseek/seek (like C) first,


    You want RandomAccessFile
    See http://mindprod.com/applet/fileio.html
    for sample code.
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Apr 22, 2008
    #3
  4. Gordon Beaton

    RC Guest

    Roedy Green wrote:

    > You want RandomAccessFile

    Thanks!
     
    RC, Apr 22, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Elephant

    Code for lseek

    Elephant, Jan 12, 2006, in forum: C Programming
    Replies:
    2
    Views:
    790
    Walter Roberson
    Jan 12, 2006
  2. venkat

    regarding lseek and fread

    venkat, May 27, 2007, in forum: C Programming
    Replies:
    2
    Views:
    447
    Martin Ambuhl
    May 27, 2007
  3. golden

    lseek and write question

    golden, Nov 16, 2007, in forum: C++
    Replies:
    3
    Views:
    591
    James Kanze
    Nov 17, 2007
  4. Kevin Walzer

    Re: PIL (etc etc etc) on OS X

    Kevin Walzer, Aug 1, 2008, in forum: Python
    Replies:
    4
    Views:
    430
    Fredrik Lundh
    Aug 13, 2008
  5. Replies:
    3
    Views:
    134
    Andreas Perstinger
    May 14, 2013
Loading...

Share This Page