Results 1 to 2 of 2
  1. #1
    Farzaneh is offline Member
    Join Date
    Aug 2008
    Posts
    8
    Rep Power
    0

    Default writing/reading a Structure to/from a file

    Hi all,
    I need to store an object of File class into a file for further use.
    I need something like reading and writing of structures into a binary file in C/C++.
    Could you please help me and tell me how to do this?

    I need to do this because my program has a text input file and every time it starts ,it should check whether it is exactly the previous file it read from and if so reading remaining of the file, but if not it should start from the beginning of the file. I decided to use File.equal() method but I don't know how to store the File object .

    Do you think my method would meet my need? If not, what's the solution?

    Thanks

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,401
    Rep Power
    25

    Default

    store an object of File class into a file for further use.
    What properites of the File class do you need to save?
    There is a writeObject method to serialize an object.
    Don't know if it will meet your need. Write a small test program and see.

Similar Threads

  1. writing and reading unicode characters from a file
    By ranoosh in forum Advanced Java
    Replies: 4
    Last Post: 09-28-2008, 04:34 AM
  2. Reading/Writing a File using byte array
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-16-2008, 10:41 AM
  3. Reading/Writing files through Applet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-15-2007, 08:20 PM
  4. Help with File reading and writing
    By baltimore in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 06:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •