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. Advertisements

  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. Advertisements

  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. Advertisements

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. Prabhu Ramachandran

    Trouble with file.seek/file.tell on Win32?

    Prabhu Ramachandran, Aug 15, 2004, in forum: Python
    Replies:
    0
    Views:
    546
    Prabhu Ramachandran
    Aug 15, 2004
  2. Prabhu Ramachandran

    Re: Trouble with file.seek/file.tell on Win32?

    Prabhu Ramachandran, Aug 16, 2004, in forum: Python
    Replies:
    2
    Views:
    655
    Christos TZOTZIOY Georgiou
    Aug 16, 2004
  3. N. Volbers
    Replies:
    3
    Views:
    463
    =?iso-8859-1?q?Lars_Gust=E4bel?=
    Jun 30, 2005
  4. Kevin Walzer

    Re: PIL (etc etc etc) on OS X

    Kevin Walzer, Aug 1, 2008, in forum: Python
    Replies:
    4
    Views:
    681
    Fredrik Lundh
    Aug 13, 2008
  5. Robert Dodier

    seek/tell in presence of multibyte characters

    Robert Dodier, Nov 24, 2006, in forum: Perl Misc
    Replies:
    7
    Views:
    321
    Brian McCauley
    Nov 26, 2006
  6. Glenn

    64-bit seek()/tell()?

    Glenn, Sep 23, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    234
    Glenn
    Sep 23, 2007
  7. Ben Temperton
    Replies:
    1
    Views:
    366
    Emile van Sebille
    Jun 14, 2012
  8. Replies:
    3
    Views:
    351
    Andreas Perstinger
    May 14, 2013
Loading...