Deleting Stings in a file

I was wondering if any one had a sample of code that would show what is the best practice for deleting strings out of a file? The same string may exisit in the file multiple times. I typically deal with SQL databases and this is the first time that I have had to do this with a regular file.
thanks

The new regular expression evaluator in 1.4.0 might be useful for what you're doing, depending on what it is. Look up the documentation for 1.4.0 and they have examples of how to use it.
http://developer.java.sun.com/developer/technicalArticles/releases/1.4regex/

Similar Messages

  • How do you delete [empty] a single file or folder from "Trash"?

    How do you delete [empty] a single file or folder from "Trash"?
    Can you "securely delete" just 1 item?

    A dangerous and incorrect shell command has been posted in this thread.
    NEVER empty the Trash in the shell (Terminal.) NEVER put anything in the Trash unless you intend to delete it immediately. If you do put something in the Trash and change your mind about deleting it, move it out or use the Put Back contextual menu item. Then empty the remaining items in the Trash as usual.

  • How to delete a READ ONLY file from Directory

    Hi Friends,
    how to delete a READ ONLY file from Directory , file is in my system only.
    Please help me .
    note: its read only file.
    Thank you.
    Karthik.

    hI,
    try with this statement.
    delete dataset <datasetname>.
    this will definitely work.
    Regards,
    Nagaraj

  • Hi Friends... I'm trying to delete a back-up file on mu TC but I get the message "The operation could not be completed because the item "bands" is in use. I'd like to start the Back from scratch, could help me out with deleting the current file?

    Hi Friends...
    I’m trying to delete a back-up file on mu TC but I get the message “The operation could not be completed because the item “bands” is in use. I’d like to start the Back from scratch, could help me out with deleting the current file?

    Sorry, I am very confused. I asked the following question....
    Is this the only backup file on your Mac, or do you have other backup files and data on the Time Capsule disk?
    The answer that you gave was....
    This is the only one
    Now you are saying that....
    But I have lots of other files on Time Capsule! The back up file is only one of them.
    Can you clarify, please?

  • How to delete data from flat file ?

    Hi all,
    I deleted a record from a tables and I want to delete it from data file.
    Can I do it ?
    Pls help me !

    What do you mean by deleting it from datafile ?, Is it flat file or something else you want to ask? I believe you have records in flat files and you want to delete them as soon as you load them into oracle table.Oracle dosent offer such facility, however you can syncronise your tables and flat file contents by using merge statements and update it in a fashion, so that only records which reflects in flat files syncronises with table in oracle database .
    hare krishna
    Alok

  • Delete partially copied movie file from iPhone. Shows grayed out in Videos on the iPhone but it doesn't show up in iTunes.

    Hello.
      I have synced my iPhone 4S with iTunes and I got an error while copying one movie. Now this movie shows up grayed out in videos on the iPhone but NOT in iTunes. Hence, I cannot delete this partially copied movie from my iPhone. And since it is grayed out, the right-to-left swipe does not work. I have resynced with "no movies" option so that every movie would be deleted and indeed every movie was deleted except for the problematic one. I rebooted the iPhone several times in case it was a glitch. No success. I even tried tools like iExplorer and DiskAid but I cannot find this **** file. Is there any way to delete this partially copied file from the iPhone without having to restore it?
    Regards,
    HawkeyeQ

    Hi adtsalmon,
    You can only watch the movie on the device you rented it on. Here's a snippet from the Apple Support site (italics mine):
    If you download a rented movie on your computer: You can transfer it to a device such as your Apple TV (1st generation), iPhone, iPad, or iPod if it’s a standard-definition film (movies in HD can only be watched on your computer, iPad, iPhone 4 or later, iPod touch (4th generation or later), or Apple TV). Once you move the movie from your computer to a device, the movie will disappear from your computer's iTunes library. You can move the movie between devices as many times as you wish during the rental period, but the movie can only exist on one device at a time.
    If you download a rented movie on your iPhone 4 or later, iPad, iPod touch (4th generation or later), or Apple TV: It is not transferable to any other device or computer.
    Here's the link to the Movie Rentals FAQs site FYI:
    http://support.apple.com/kb/HT1657
    Hope this helps!
    Cheers,
    GB

  • How to repair my macbook pro when i had delete the app store file and know it telling that appstore file has been damage or incomplete and i had the version 10.6.8

    how to repair my macbook pro when i had delete the app store file and know it telling that appstore file has been damage or incomplete and i had the version 10.6.8

    so is their is any way that i can solve this matter

  • How can I delete my entire History file, without doing it one site at a time?

    I am able to delete a given site in my History file by right-clicking on it and indicating to delete it. How do I erase the entire file when it is no longer of any use to me?

    You can delete the places.sqlite file to remove all history.
    Firefox will use the most recent JSON backup in the bookmarkbackups folder to rebuild the bookmarks.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox

  • How can I delete the photos or files in my iCloud storage that is no longer needed?

    How can I delete the photos or files in my icloud storage that is no longer needed?

    Explain how it didn't work and what you are trying to delete.  Since icloud doesn't store photos except for those in a backup (then delete the backup); photos in photo stream do not count towards your storage limit.

  • Deleting more than one file at a time from Nomad Jukebox Zen Xtra 4

    Is there a way to delete more than one file at a time from Zen Xtra? Actually, I'd like to delete most of the 800+ files and the only way I've found is to do them one at a time..! Help!

    Either use finder to drag and drop those tracks onto
    "Library" in iTunes' left "Source" column or from
    iTunes Menu Files use "Add to Library ..." then
    navigate to a folder that keep a yoru tracks and
    select that folder.
    This did it! I was doing an "import" which would only let me do one song at a time. But the "add to library" and the drag and drop both worked. Thanks!!!
    New Mac user
    Scott in Alaska
    MacBookPro   Mac OS X (10.4.5)  

  • To delete Data From a file

    i want to delete lines from a file after reading the line. the next time i read the file i should find a unread line as the 1st line of the file.
    how do i do tat? this is very similar to delete from table name query in sql. but i have to do this with java and txt files. how do i code this??

    You can't delete part of a file. The way to do that in general is like this:
    1. Read a line.
    2. If you want to delete it, do nothing. Otherwise write it to a new file.
    3. Repeat until end-of-file.
    After you've finished all that, the new file will contain everything you didn't want to delete. Now delete the original file and rename the new file to have its name.

  • Slow loading when creating a new folder or deleting a folder or file

    Hello! Before we begin, a little information. This problem only started occurring AFTER I updated to Mavericks. I have been through every operating system since Snow Leopard and NEVER had this problem until Mavericks. It has been palguing me since I updated in October and I need some answers. Seeing as how I do not feel like paying $59 to ask apple for help in this matter I'm coming to the community. This is an odd problem where finder doesn't seem to want to load certain actions properly. In my case, creating a new folder, deleting a folder or file, and using the "always open with" function.
    In terms of creating a new folder, anywhere in finder, the folder will not appear immedlately, insetad it takes a staggering 5-10 seconds to appear where I created it. For deleting a folder or file, the same thing happens. It takes a huge amount of time to move the folder or file to the trash bin, UNLESS I open a different folder or file in the same directory after deleting said folder or file, in which case it moves right away. And the "always open with" checkbox just doesn't work at all.
    About my platform: Intel iMac (Late 2009) 3.6 GHz Intel Core 2 Duo, 12 GB 1067 MHz DDR3, 220 out of 499.75gb hard drive space. OS X version 10.9.2
    Thanks in advance for any help in these matters.
    You guys helped me solve the unchangeable background problem when apple couldn't, so I'm reaching out to you again for that awesome support I know you guys have in you

    Adobe contacted me and had me reset my prefereneces for flash using their steps. I have done that and a complete uninstall/re-install and searched for corrupted fonts and still I am having the same issue and adobe support appears to have just left me hanging.
    Is there anyone here who has experienced this same issue that can offer any assistance to solve this issue. As it stands right now I have a product I cannot even use and that is troublesome to say the least.
    Thanks for any help you can offer.

  • Deleting data from text files

    Hi there,
    I am having a real battle trying to delete data from a text file I am using. There seems to be this giant cloud with Java, where there is no real easy way to delete text from a file??
    I have a JFrame with two textfields on it where you enter the username and pcname. There is a OK button once you have entered those details.
    On action event I would like those two details, to be removed from the text file that has been read in.
    I have a text file like this:
    bob
    pc1
    bill
    pc2
    The data above gets written no problem, one at at a time using the below.
    File f = new File("\\c:\\filename.txt");
    String strToWrite;
    try
    FileOutputStream fstr = new FileOutputStream(f);
    strToWrite = username1+ '\r'+'\n' ;
    byte[] bytes = strToWrite.getBytes(); fstr.write(bytes);
    strToWrite = pcname1 + '\r'+'\n' ;
    byte[] bytes2 = strToWrite.getBytes(); fstr.write(bytes2);
    strToWrite = username2+ '\r' +'\n' ;
    byte[] bytes3 = strToWrite.getBytes(); fstr.write(bytes3);
    strToWrite = pcname2 + '\r'+'\n' ;
    byte[] bytes4 = strToWrite.getBytes(); fstr.write(bytes4);
    catch (IOException e)
    System.out.println("Error -- " + e.toString());
    To read them back in I have made the follwoing:
    BufferedReader br= null;
    Count = 0;
    try
    br = new BufferedReader(new InputStreamReader(new FileInputStream("\\c:\\filename.txt")));
    String s = "";
    while((s=br.readLine()) != null )
    Count = 1;     
         //System.out.println("Data is " + s);
         inboundtext = s;
         if ( Count == 1 )
    break;
    while((s=br.readLine()) != null )
    //System.out.println("Data is " + s);
    inboundtext = s;
    Count = 2;
    if ( Count == 2 )
    break;
    catch(IOException ie)
    finally
    try
         if(br!=null) br.close();
    catch(Exception e)
    Now the above I know, is reading each line of the text file one at a time.
    Now what I would like is that when the text that we got from the textfields, using getText(), be removed from the file without destroying the rest of the records in there? Why is it so easy to add and replace files, but not do any deleting from them?
    please help!!

    sorry, FileOutputStream fstr = new FileOutputStream(f);
    should be FileOutputStream fstr = new FileOutputStream(f, true);

  • I deleted all my iTunes files and need help recreating them.

    Hello everyone
    I accidentlly deleted all the iTunes files (NOT the content, just the files iTunes uses in its database). When I tried to create a new database, iTunes moved all my my music videos into the Movies or Home videos, which I don't want. I have a copy of my folder set up that I want iTunes to use and to not alter (exactly as it was before I deleted the files). Here is what I thought I need to do. Please corect me if I am wrong:
    1. remove all the files that iTunes has relocated to different folders (IE, basically delete them all)
    2. copy the folders onto the drive I use for my media
    3. start itunes
    4 unselect Keep my files organized
    5. scan the folders
    6. Select all the music and videos and classify them as "Music" or "Music Videos"
    This should keep all the files in the same folders as the backup copy, without moving them to Videos or Home Videos. I assume this will also retain the current Artist / Album / Song hierarchy.
    Is this correct?
    Any better way to do this?
    Thanks everyone who can help!
    JoHN

    1) If you bought them from Apple you canprobably download them again.
    2) If you back up your computer as you should, they will be on the backup.
    3) If you stop using your computer this instant (because as you use the computer it overwrites deleted files even if you have lots of space), buy recovery software ($100+), there is a  chance you can recover some of them, though they may have lost filenames and will be in quite a mess.

  • I have backed up my disk using Time Machine.  Now I want to delete the backed-up files from my hard drive.  But when I do and reconnect the external hard drive, the files are also deleted on that.  What do I do?

    I have backed up my disk using Time Machine.  I then deleted the back-up files from my MacBook hard drive.
    I then reconnected my external hard drive and find the files I deleted from my hard drive are also deleted from
    my external hard drive.  Can someone tell my what what happened?  I'm confused.

    Hello,
    Time Machine is not a good way to do that, when it eventually needs more room it deletes old Backups to make room.
    If you really want to keep Files but remove them from the Internal Drive, then I'd get another external drive to copy or clone them to that is not used for TM.

Maybe you are looking for