Results 1 to 2 of 2
Thread: Regarding File Handling
- 01-20-2010, 12:24 PM #1
Member
- Join Date
- Jun 2008
- Posts
- 87
- Rep Power
- 0
Regarding File Handling
Hi
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
2nd FileJava Code:.../a.exe .../b.exe .../c.exe
Now i want to delete the button that is present in ../b.exeJava Code:../a.png ../a.png ../a.png
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
- 01-20-2010, 09:15 PM #2
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
and then the operation of reading, and deleting a line is now entirely different, delete lines in pairs right.Java Code:.../a.exe ../a.png .../b.exe ../a.png .../c.exe ../a.png
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
-
file handling problem
By gcampton in forum EclipseReplies: 19Last Post: 01-05-2010, 01:18 PM -
handling WAV file
By zellazode in forum New To JavaReplies: 1Last Post: 09-08-2009, 03:46 PM -
Sms handling in j2ee
By prts_mfs in forum Java ServletReplies: 1Last Post: 04-22-2009, 08:40 AM -
Problem in File Handling in Java
By getbiplab in forum New To JavaReplies: 6Last Post: 03-31-2008, 12:02 PM -
Exception Handling...
By focus_nitin in forum New To JavaReplies: 1Last Post: 02-16-2008, 03:13 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks