How can I substitute a string with another string in a file

I have a file. I have a substitute a keyword with another string in all the occurences of a file. How can I do this?

I'm gonna give you the benifit of the doubt and assume you didn't mean to double post your question.
As to substitute a keyword with a string one way is to read in the file and run it through a StreamTokenizer class to break it into words. Pull one word at a time, check it, and stick it into a StringBuffer. Once your done with the file overwrite it with what is in the StringBuffer.
Another way might be to use the RandomAccessFile class, but I'm not really familiar with that because I hardly ever use it.

Similar Messages

  • How to replace a particular striing with another string in jtextpane

    how to get replace a particular string with another string of a jtextpane without taking the text in a variable using getText() method .

    Thanks for your answer,
    "relevant object" means for you datasources, transfer rules and transformations ?
    With the grouping option "Save for system copy" I can't take easily all datasources, and others objects
    Will I have to pick all object one by one ?
    What would be the adjustement in table RSLOGSYSMAP ? For the moment it's empty.
    Regards
    Guillaume P.

  • HT204266 how can I update my app with another account?

    how can I update my app with another account?

    kambiz.fakhr wrote:
    how can I update my app with another account?
    Anything Downloaded with a Particular Apple ID is tied to that Apple ID and Cannot be Merged or Transferred to a Different Apple ID
    Apple ID FAQs  >  http://support.apple.com/kb/HT5622

  • My pc broke! How can I syncronize my iphone with another pc?

    My pc broke! How can I syncronize my iphone with another pc?

    You can only sync with one computer, do you not have a backup of your library to transfer to the new computer?
    If not the only way is to transfer purchases
    http://support.apple.com/kb/ht1848
    http://support.apple.com/kb/ht1727
    For non-purchased content you will need to find a 3rd party app

  • How can I share my screen with another apple computer?

    How can I share my screen with another apple computer?

    By enabling Screen Sharing in the Sharing preferences. Both computers need to be connected to your local network, preferably by Ethernet.

  • Replacing a special character in a string with another string

    Hi
    I need to replace a special character in a string with another string.
    Say there is a string -  "abc's def's are alphabets"
    and i need to replace all the ' (apostrophe) with &apos& ..which should look like as below
    "abc&apos&s def&apos&s are alphabets" .
    Kindly let me know how this requirement can be met.
    Regards
    Sukumari

    REPLACE
    Syntax Forms
    Pattern-based replacement
    1. REPLACE [{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF]
    pattern
              IN [section_of] dobj WITH new
              [IN {BYTE|CHARACTER} MODE]
              [{RESPECTING|IGNORING} CASE]
              [REPLACEMENT COUNT rcnt]
              { {[REPLACEMENT OFFSET roff]
                 [REPLACEMENT LENGTH rlen]}
              | [RESULTS result_tab|result_wa] }.
    Position-based replacement
    2. REPLACE SECTION [OFFSET off] [LENGTH len] OF dobj WITH new
                      [IN {BYTE|CHARACTER} MODE].
    Effect
    This statement replaces characters or bytes of the variable dobj by characters or bytes of the data object new. Here, position-based and pattern-based replacement are possible.
    When the replacement is executed, an interim result without a length limit is implicitly generated and the interim result is transferred to the data object dobj. If the length of the interim result is longer than the length of dobj, the data is cut off on the right in the case of data objects of fixed length. If the length of the interim result is shorter than the length of dobj, data objects of fixed length are filled to the right with blanks or hexadecimal zeroes. Data objects of variable length are adjusted. If data is cut off to the right when the interim result is assigned, sy-subrc is set to 2.
    In the case of character string processing, the closing spaces are taken into account for data objects dobj of fixed length; they are not taken into account in the case of new.
    System fields
    sy-subrc Meaning
    0 The specified section or subsequence was replaced by the content of new and the result is available in full in dobj.
    2 The specified section or subsequence was replaced in dobj by the contents of new and the result of the replacement was cut off to the right.
    4 The subsequence in sub_string was not found in dobj in the pattern-based search.
    8 The data objects sub_string and new contain double-byte characters that cannot be interpreted.
    Note
    These forms of the statement REPLACE replace the following obsolete form:
    REPLACE sub_string WITH
    Syntax
    REPLACE sub_string WITH new INTO dobj
            [IN {BYTE|CHARACTER} MODE]
            [LENGTH len].
    Extras:
    1. ... IN {BYTE|CHARACTER} MODE
    2. ... LENGTH len
    Effect
    This statement searches through a byte string or character string dobj for the subsequence specified in sub_string and replaces the first byte or character string in dobj that matches sub_string with the contents of the data object new.
    The memory areas of sub_string and new must not overlap, otherwise the result is undefined. If sub_string is an empty string, the point before the first character or byte of the search area is found and the content of new is inserted before the first character.
    During character string processing, the closing blank is considered for data objects dobj, sub_string and new of type c, d, n or t.
    System Fields
    sy-subrc Meaning
    0 The subsequence in sub_string was replaced in the target field dobj with the content of new.
    4 The subsequence in sub_string could not be replaced in the target field dobj with the contents of new.
    Note
    This variant of the statement REPLACE will be replaced, beginning with Release 6.10, with a new variant.
    Addition 1
    ... IN {BYTE|CHARACTER} MODE
    Effect
    The optional addition IN {BYTE|CHARACTER} MODE determines whether byte or character string processing will be executed. If the addition is not specified, character string processing is executed. Depending on the processing type, the data objects sub_string, new, and dobj must be byte or character type.
    Addition 2
    ... LENGTH len
    Effect
    If the addition LENGTH is not specified, all the data objects involved are evaluated in their entire length. If the addition LENGTH is specified, only the first len bytes or characters of sub_string are used for the search. For len, a data object of the type i is expected.
    If the length of the interim result is longer than the length of dobj, data objects of fixed length will be cut off to the right. If the length of the interim result is shorter than the length of dobj, data objects of fixed length are filled to the right with blanks or with hexadecimal 0. Data objects of variable length are adapted.
    Example
    After the replacements, text1 contains the complete content "I should know that you know", while text2 has the cut-off content "I should know that".
    DATA:   text1      TYPE string       VALUE 'I know you know',
            text2(18)  TYPE c LENGTH 18  VALUE 'I know you know',
            sub_string TYPE string       VALUE 'know',
            new        TYPE string       VALUE 'should know that'.
    REPLACE sub_string WITH new INTO text1.
    REPLACE sub_string WITH new INTO text2.

  • Replace a string with another string in a file

    I have to replace a string with another string. Say for example in a html file it got a line like,
    <a href="##"></a>
    now i want to replace this ## with the full derived path like
    "c;\\sample folder\\sample subfolder\\samplefile.html"
    can someone help me to do this?
    pls tell me from the file opening till closing the file.

    I have to replace a string with another string. Say
    for example in a html file it got a line like,
    <a href="##"></a>
    now i want to replace this ## with the full derived
    path like
    "c;\\sample folder\\samplesubfolder\\samplefile.html"
    can someone help me to do this?
    pls tell me from the file opening till closing the
    file.
    public class Buckel {
      final static String CONST = "c:\\sample folder\\samplesubfolder\\samplefile.html";
      public Buckel() {
      public static void main ( String[] argv )  throws Exception {
        int    idx = 0;
        String in  = "<a href=\"##\"></a>",   // We'll imagine this just gets here somehow. If it's on the i/p file then take the '\' out B4 and aft the '##'.
               out = "";
        idx = in.indexOf( "##" );
        if ( idx > 0 ) {
          out = in.substring( 0, idx ) + CONST + in.substring( idx+=2, in.length() );
        System.out.println( out );
    }

  • How can i create  excel sheet with multiple tabs using utl file?

    how can i create excel sheet with multiple tabs using utl file?
    any one help me?

    Jaggy,
    I gave you the most suitable answer on your own thread yesterday
    Re: How to Generating Excel workbook with multiple worksheets

  • How can I share contact list with another MAC

    How can I share my contact list with another MAC?

    Hi,
    There does seem to be a presumption in the other reply that your girlfriend is living with you.
    A File transfer via Bonjour would then work.
    Also the File Sharing in System Preferences > Sharing would cause her computer to show up on your Finder's side bar as a Share.
    With iChat if you both have AIM Login names you could still do File Transfers.
    (It is slightly more complicated if you have Jabber ID logged in alothough not impossible).
    9:54 PM      Sunday; January 15, 2012
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
      iMac 2.5Ghz 5i 2011 (Lion 10.7.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • HT204053 how can i home share photos with another apple id

    How can I share photos through home sharing with 2 apple ID. I have an Iphone and my wife does also but we created 2 ID's because we want our contacts to stay separated and we still want to view our pictures from our main desktop?

    Welcome to the Apple Community.
    In order to change your Apple ID or password for your iCloud account on your iOS device, you need to delete the account from your iOS device first, then add it back using your updated details. (Settings > iCloud, scroll down and hit "Delete Account")
    Providing you are simply updating your existing details and not changing to another account, when you delete your account, all the data that is synced with iCloud will also be deleted from the device (but not from iCloud), but will be synced back to your device when you login again.
    In order to change your Apple ID or password for your iCloud account on your computer, you need to sign out of the account from your computer first, then sign back in using your updated details. (System Preferences > iCloud, click the sign out button)

  • How can I share a playlist with another iOS device that they can play when they're offline?

    I have created a playlist in iTunes for someone in my family and have authorised him for home sharing. He can listen to the playlist when on our wifi at home, but how can he listen to it on his iPhone when he is away from home?

    What you are asking isn't possible as devices must be logged in to the same wifi and with the same Apple ID for Home Sharing to work.

  • HT3819 How can I share my music with another apple ID device

    Can I share the music on my iPad with another iPad, the other iPad has a different Apple ID

    The correct answer to your question is No - you cannot "share" Music with another device using a different Apple ID. Can you make it work - yes you can.
    You do not want to sign into the other Apple ID and download the purchased music because you will lock yourself out of your own Apple ID for 90 days. Apple does this in order to discourage users from "sharing" purchased content that they did not buy themselves.
    Whatever you decide to do, just don't download the music from the purchased tab in iTunes, because you don't want to lock yourself out of your own ID for 90 days.
    iTunes Store: Associating a device or computer to your Apple ID

  • How can I sync my iPod with another iPod as I use the same iTunes account?

    I currently have an iPod Nano and want to go for an iPod Touch soon. My iPod Nano has a lot of iTunes music that I’d rather not have to pay for a second time. How can I get that music on to my new iPod without having to pay for it again?

    The best approach would be to register your new iPod to your current iTunes account then sync to the matching library much like your old one. You can learn more about BACKING UP and managing content simply by downloading and reading on your user guide.

  • How can I sync my iPhone with another iTunes Library, but be able to keep my songs?

    I logged onto my computer and all my iTunes music was suddenly gone. It was almost like it had deleted itself. Now I can't find the same Library I was using before and can't download music. If I try to sync it to another computer, it will delete all the songs i have now.

    I had the same issue with a withdrawn app. Just copy all the .app files from the old directory to somewhere on the new machine, then drag them onto the Application menu item on the left hand side and iTunes will import them as long as you've already registered iTunes for the same account.
    Job done! Worked a treat for me - including the app that wasn't available any more.....

  • How can I best use iCloud with another cloud based server

    Here is what I want to accomplish.  I have switched ISP's and wish to have all my email based in the cloud, so another switch of ISP is not so painful.  I have 2 accounts I monitor, iCloud for personal use, and another server for my website for business use.  I want to simply look at one mail box, that is iCloud that contains all email I route ... so, forward to the business server to Icloud and read iCloud from my mac, web browse, or ipad/cellphone.  So far OK.  The fly in the ointment is that I want to send emails with either my personal or business address from my mac or wherever, and can see no way to have both addresses available for sending, just the icloud based ones.
    Advice is wanted and appreciated.
    Thanks, Dan

    You can use different accounts for each of your devices, but why?  Then they couldn't sync with each other (and the icloud account they are associated with).
    But each device can only be associated with one icloud account, you can't have each connect to both accounts.  It seems you are trying to gain additional storage by using a second account.  To have both devices connecting to the same data and use more storage, you'll have to buy more.

Maybe you are looking for

  • Error 9006

    Whenever I purchase a song or album it stops downloading and gives an error: err = 9006. Does anyone know what this means and how I can fix it?   Windows XP  

  • Updating MDM table when another table gets updated

    Hi Guys, We use MDM catalog for SRM we have a table Catogories and Hierarchy, Our requirement is when ever Catogories table gets updated we have to update the Hierarchy table using some logic, So please let me know whether it is possible to do this a

  • Iterate through XML tags of file (CS5)

    Hello! I'd like to iterate through an XML file, but I am not sure how to do this, since the import is mostly done automatically. This is how I load and import the file: var f = new File('~/Desktop/test.xml'); app.activeDocument.importXML(f);   But ho

  • My Macbook Pro just started shutting down when I connect my IPhone to the laptop. Help please.

    Everytime I connect my Iphone 4 to my Macbook Pro (purchased in 2006), the computer shuts down and reboots automatically before IPhoto even opens. I need to back up my IPhone so I can upgrade. PLEASE HELP!

  • Cannot access setup page.

     My wrt54g works but I cannot access the setup page. A partial page does appear but with no tabs. I am using W98SE. None of the available download software accepts w98 and this forum is definitely a work in progress.