Results 1 to 2 of 2
  1. #1
    ravjot28 is offline Member
    Join Date
    Jun 2008
    Rep Power

    Default Regarding File Handling

    I made a project in which i am using 2 files

    1st file contains the path of the programs
    2nd file contains the associated image icon's path

    Now when i want to delete a button (which is using both data from the above files)
    At that time it is easy to delete the program path from 1st file

    But it is difficult for me to delete the icon's path from 2nd file as 2nd file may contain same image icon like others so how can overcome such a problem

    1st File

    Java Code:
    2nd File

    Java Code:
    Now i want to delete the button that is present in ../b.exe
    I can delete it from 1st File
    but how should i delete from 2nd file?
    Can you provide me a snippet so that it will be easy for me to understand
    Thanks in advance

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Rep Power


    I was going to ask why not have a structured file that allows for both the storage of the file name path and the image icon, such as on the same line, using delimiters, or fixed field delimted, or an XML format?

    Or maybe to have a file structured where every odd line is the file path and every even line is the image, so that you woul dhave
    Java Code:
    and then the operation of reading, and deleting a line is now entirely different, delete lines in pairs right.

    or i guess, logically, if you know you want to delete b.exe from the first file, to first determine what line number this is on in the first file, when you delete this line, open the second file, and delete this same line number from the second file.,

    where i know i have a previous post somewhere in this forum about how to read a specific line from a file. though in the delete case, i think we might need create a temporary file copy, like to create some temporary file, read every line up to before the line we want to delete into this temporary file, skip the line, and read every line after the line we want to delete, then save the file, and remove the existing file and move the temporary file back to the original file path name.

    Yes, that sounds messy to me, it is likely much more optimal to do it using the java.nio.channels.FileChannel, to adjust the contents in the file after the line we want to remove to 'up' in the file. but this API is not line oriented, you would need to compute the bytes in the file offset of the start and end of the line to be deleted.

Similar Threads

  1. file handling problem
    By gcampton in forum Eclipse
    Replies: 19
    Last Post: 01-05-2010, 01:18 PM
  2. handling WAV file
    By zellazode in forum New To Java
    Replies: 1
    Last Post: 09-08-2009, 03:46 PM
  3. Sms handling in j2ee
    By prts_mfs in forum Java Servlet
    Replies: 1
    Last Post: 04-22-2009, 08:40 AM
  4. Problem in File Handling in Java
    By getbiplab in forum New To Java
    Replies: 6
    Last Post: 03-31-2008, 12:02 PM
  5. Exception Handling...
    By focus_nitin in forum New To Java
    Replies: 1
    Last Post: 02-16-2008, 03:13 AM

Posting Permissions

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