What is the best way of replacing words in a text file ?

i want to read in a text file and when i come across a certain word, i want to change it to something else. Whats the best way to do this ?
If i read in a line at a time, how would i only replace one word and not the rest of the line ?
thanks

thanks it works !!! But i wrote the contents to a new file.
How do i overwrite the same file ? I put the the input and output file as the same location but it overwrites the original file with a blank one.
i guess i have to write into another buffer and read all lines first before overwriting the file right ? how should i do that ?
also, i only want to overwrite the file ONLY if applies replaceAll method, otherwise if no replacing takes place i dont want to keep updating the file everytime.

Similar Messages

  • What is the best way to import word documents from a PC to the Ipad2

    What is the best way to import word documents from a PC to the Ipad 2?

    You first need an app on the iPad that supports word documents - the iPad doesn't have a file structure like a 'normal' computer, and every file/document needs to be associated with an app. If you don't have such an app then options include Apple's Pages app and third-party apps such as Documents To Go and QuickOffice HD. How you then get the documents on the iPad will depend upon the app that you have/get as different apps may use different methods e.g. via the file sharing section at the bottom of the device's apps tab when connected to iTunes, via wifi, email, dropbox etc.

  • What's the best way to replace front glass on an iPhone 4?

    My grandson has a 4 and has cracked the front glass. Trying to find the best cost effective way to replace the glass.

    i don\'t want an alias!! wrote:
    What's the best way to replace front glass on an iPhone 4?
    Take it to an Apple Store for out of warranty exchange fro $149.
    This way you get a refurb iPhone including new battery.
    See this -> http://support.apple.com/kb/index?page=servicefaq&geo=United_States&product=ipho ne
    Out-of-Warranty Service
    If you own an iPhone that is ineligible for warranty service but is eligible for Out-of-Warranty (OOW) Service, Apple will service your iPhone for the Out-of-Warranty Service fee listed below.
    iPhone model
    Out-of-Warranty Service
    iPhone 5s, iPhone 5c,
    iPhone 5
    $269
    iPhone 4S
    $199
    iPhone 4, iPhone 3GS,
    iPhone 3G, Original iPhone
    $149

  • What is the best way to replace the Inline Views for better performance ?

    Hi,
    I am using Oracle 9i ,
    What is the best way to replace the Inline Views for better performance. I see there are lot of performance lacking with Inline views in my queries.
    Please suggest.
    Raj

    WITH plus /*+ MATERIALIZE */ hint can do good to you.
    see below the test case.
    SQL> create table hx_my_tbl as select level id, 'karthick' name from dual connect by level <= 5
    2 /
    Table created.
    SQL> insert into hx_my_tbl select level id, 'vimal' name from dual connect by level <= 5
    2 /
    5 rows created.
    SQL> create index hx_my_tbl_idx on hx_my_tbl(id)
    2 /
    Index created.
    SQL> commit;
    Commit complete.
    SQL> exec dbms_stats.gather_table_stats(user,'hx_my_tbl',cascade=>true)
    PL/SQL procedure successfully completed.
    Now this a normal inline view
    SQL> select a.id, b.id, a.name, b.name
    2 from (select id, name from hx_my_tbl where id = 1) a,
    3 (select id, name from hx_my_tbl where id = 1) b
    4 where a.id = b.id
    5 and a.name <> b.name
    6 /
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=7 Card=2 Bytes=48)
    1 0 HASH JOIN (Cost=7 Card=2 Bytes=48)
    2 1 TABLE ACCESS (BY INDEX ROWID) OF 'HX_MY_TBL' (TABLE) (Cost=3 Card=2 Bytes=24)
    3 2 INDEX (RANGE SCAN) OF 'HX_MY_TBL_IDX' (INDEX) (Cost=1 Card=2)
    4 1 TABLE ACCESS (BY INDEX ROWID) OF 'HX_MY_TBL' (TABLE) (Cost=3 Card=2 Bytes=24)
    5 4 INDEX (RANGE SCAN) OF 'HX_MY_TBL_IDX' (INDEX) (Cost=1 Card=2)
    Now i use the with with the materialize hint
    SQL> with my_view as (select /*+ MATERIALIZE */ id, name from hx_my_tbl where id = 1)
    2 select a.id, b.id, a.name, b.name
    3 from my_view a,
    4 my_view b
    5 where a.id = b.id
    6 and a.name <> b.name
    7 /
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=8 Card=1 Bytes=46)
    1 0 TEMP TABLE TRANSFORMATION
    2 1 LOAD AS SELECT
    3 2 TABLE ACCESS (BY INDEX ROWID) OF 'HX_MY_TBL' (TABLE) (Cost=3 Card=2 Bytes=24)
    4 3 INDEX (RANGE SCAN) OF 'HX_MY_TBL_IDX' (INDEX) (Cost=1 Card=2)
    5 1 HASH JOIN (Cost=5 Card=1 Bytes=46)
    6 5 VIEW (Cost=2 Card=2 Bytes=46)
    7 6 TABLE ACCESS (FULL) OF 'SYS_TEMP_0FD9D6967_3C610F9' (TABLE (TEMP)) (Cost=2 Card=2 Bytes=24)
    8 5 VIEW (Cost=2 Card=2 Bytes=46)
    9 8 TABLE ACCESS (FULL) OF 'SYS_TEMP_0FD9D6967_3C610F9' (TABLE (TEMP)) (Cost=2 Card=2 Bytes=24)
    here you can see the table is accessed only once then only the result set generated by the WITH is accessed.
    Thanks,
    Karthick.

  • What's the best way to replace a 60 W Mag Safe Power Adapter?

    What's the best way to replace a 60 W Mag Safe Power Adapter for a Macbook Pro?

    Buy one from Apple!!

  • Hi, what's the best way to replace IMAC 27'' glass when broken (latest Imac generation from end 2012) ?  Thanks,

    Hi, what's the best way to replace IMAC 27'' glass when broken (latest Imac generation from end 2012) ?  Thanks,

    Not sure about the 2012 models but the 2010 ones can be removed in seconds, using a suction cup on the top corner. I use my tomtom to lift it away. It is attached by magnets.
    Hope this helps.

  • This community is great -- very helpful. What is the best way to read "word" docs on my brand new iPad 2? Is there an app for that?

    This community is great -- very helpful. What is the best way to read "word" docs on my brand new iPad 2? Is there an app for that?

    If you're just reading them from email attachments, you can just open it to "view" the document.
    However, if you wish to do editing and work, you'll need an application. I use Documents to Go, but there are other versions that people are happy with - do a search in the App store for "office suite" or "word processing".
    The next challenge is getting docs back and forth. Doc2Go and others have their own ways to physically sync docs when connected to a computer; you can also email changed/revised/new documents from the iPad to yourself. However, I use a "cloud service" called DropBox that stores docs in the cloud (so I can get to them anywhere) - I paid for the Premium version of Docs2Go to allow that kind of syncing.

  • V11, What is the best way to replace ImportSecurity.cmd

    Hello,
    I've migrated my essbase/planning server from 9.3.1 to V11.1.1.2.
    I previously used ImportSecurity.cmd to load security on members of outlines and on data forms in Planning. But now it seems that ImportSecurity.cmd is no more available in V11 (or I may have forgot to install / configure something ??).
    So what is the best way to load security automatically now in V11 ?
    Thanks for your help
    Regards

    Hi,
    You can use LCM (Lifecycle management now)
    Have a look at :- http://download.oracle.com/docs/cd/E12825_01/epm.111/epm_lifecycle_management_11111/launch.htm
    Or have a read [here |http://john-goodwin.blogspot.com/2008/08/so-whats-this-life-cycle-management-all.html] for an overview.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Upgrading to SSD, what is the best way to clean install and transfer my files over?

    I am upgrading to an SSD and I would like to start clean by doing a fresh installation of Yosemite on the new drive. However, I still want all of my personal files from my current hard drive, like my music, music libraries, photos, and Home folder, transferred over to the new drive. What is the best way of doing this?
    I have Time Machine and a Time Capsule. Could I simply restore a Time Machine backup, or will that defeat the purpose of doing a clean install?
    Should I just back up the home folder and transfer the home folder onto an external drive, then drag the home folder to my new drive? Will that save my iTunes playlists and music?
    I don't need to transfer apps over so I'm not worried about that. Just my documents, files, pictures, music.

    How to replace or upgrade a drive in a laptop
    Step One: Repair the Hard Drive and Permissions
    Boot From An OS X Installer Disc
    1. Insert OS X Installer Disc into the optical drive.
      2. Restart the computer.
      3. Immediately after the chime press and hold down the "C" key.
      4. Release the key when the spinning gear below the dark gray Apple
          logo appears.
      5. Wait for installer to finish loading.
    Boot From a Recovery HD:
      1. Restart the computer.
      2. Immediately after the chime press and hold down the
          "COMMAND" and the "R" keys together.
      3. Release the keys when the Utilities Menu appears.
    After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Installer menu (Utilities menu for Tiger, Leopard, Snow Leopard and later.)
    For Lion or later select Disk Utility from the Utilities Main Menu.
    After Disk Utility loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the Disk Utility status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If Disk Utility reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    Step Two: Remove the old drive and install the new drive.  Place the old drive in an external USB enclosure.  You can buy one at OWC who is also a good vendor for drives.
    Step Three: Boot from the external drive.  Restart the computer and after the chime press and hold down the OPTION key until the boot manager appears.  Select the icon for the Recovery HD on the external drive, then click on the downward pointing arrow button.
    Step Four: New Hard Drive Preparation
      1. Open Disk Utility from the Utility Main Menu, then click on the Continue button.
      2. After Disk Utility loads select your new hard drive (this is the entry with the
          mfgr.'s ID and size) from the left side list. Note the SMART status of
          the drive in DU's status area.  If it does not say "Verified" then the drive
          is failing or has failed and will need replacing.  Otherwise, click on the
          Partition tab in the Disk Utility main window.
      3. Under the Volume Scheme heading set the number of partitions from
          the drop down menu to one. Set the format type to Mac OS Extended
          (Journaled.) Click on the Options button, set the partition scheme to
          GUID  then click on the OK button. Click on the Partition/Apply button and
          wait until the process has completed.
      4. Select the volume you just created (this is the sub-entry under the
          drive entry) from the left side list. Click on the Erase tab in the DU main
          window.
      5. Set the format type to Mac OS Extended (Journaled.) Click on the
          Options button, check the button for Zero Data and click on OK to
          return to the Erase window.
      6. Click on the Erase button. The format process can take up to several
          hours depending upon the drive size.
    Step Five: Clone the old drive to the new drive
      1. Select the destination volume from the left side list.
      2. Click on the Restore tab in the DU main window.
      3. Check the box labeled Erase destination.
      4. Select the destination volume from the left side list and drag it to the
          Destination entry field.
      5. Select the source volume from the left side list and drag it to the
          Source entry field.
      7. Double-check you got it right, then click on the Restore button.
    Destination means the new internal drive. Source means the old external drive.
    Step Six: Open the Startup Disk preferences and select the new internal volume.  Click on the Restart button.  You should boot from the new drive.  Eject the external drive and disconnect it from the computer.

  • What is the best way to split large blocks of text into smaller blocks?

    Hello, I have several pages with 2,000 word articles of text. As you can imagine these pages are not terribly interesting design-wise, something I plan to change.
    The first thing I need to do is split up these blocks of text into much smaller blocks so that they can easily be moved around and independently manipulated. What's the quickest way to do this in Muse?

    You can create different text frames and copy the text, which if you wish you can group them together which will help in moving them around on page.
    Thanks,
    Sanjit

  • What's the best way to export a 1280:720 mov file to high res wmv

    Does anyone know the best way to export an HD 1280:720 Quick Time .mov to the highest possible res wmv?

    fewer problems. It was a codec issue, I think regarding the latest codec. The solution, and it works for all the apps, was to make the frame divisible by 16 on all sides. It had to do with coding factors. But it worked. Since then, and the introduction of the iPad, we've dropped WMV altogether. We're now relying on Flash and MP4. MP4 is used in most places, particularly promos and marketing content. However, it's not at all easy to protect content from "redistribution" when using HTML5. It has a weakness in which it leaves a data trail that someone can follow back to the original video. Hmmm... so we code in a Flash wrapper, though I think my IT person may be using my MP4s for that. I'll have to check. Anyway, I'm down to mostly MP4 now.

  • After finally completing  a clean install what is the BEST way to replace my data.

    Please understand I moved from PC to Mac in Late 2011. Unlike windows where you have to know how it all works to use it, Mac is so simple I, to my own detriment , did not take the time to learn more than just my daily use. Been busy moving country and other crazy life stuff. I am rectifying this mistake. I did have issue with the clean install process working through with out interruption, some file issue, so had to repeat a few times.
    1. completed a clean install through to completion of set up, new account etc. Machine runs amazingly better. Completed updates. Knowing Migration Assistant can deal with duplicate user issues.
    Q? Do I need to run disk repair or other.
    2. Thought myself ill equipped with knowledge and understanding to manually replace my data via finder. I simply do not know where things are supposed to go.
    3. Tried reinstall of everything thru set up but it installed everything including all the issues I had before. Went through clean install process again.
    4. With this in mind I am hesitant and very weary to use Migration Assistant to move everything back as I simply do Not know where the issue lies even if it allowed greater folder & file separation.
    I have got to the stage where I am ready to recover my data which is on my backup external hard drive. The data was recovered using Time Machine.
    I wish to do what is best for my machine. It is getting older and I wish to do what I can for its longevity.
    Q? So what data is best recovered in which way and in what order.
    5. Is it best to say do recover applications from App Store and redo all updates if required.
    Then install non app store apps, e.g. Microsoft office for mac, and others thru finder.
    Users thru Migration assistant  etc etc.
    Been learning and working on this since my last post. Lots of watching YouTube and reading for hours.
    So much conflicting opinions and maybe this is due to my lack of specifics and most posts are for general use so I do understand.
    Again thank you in advance. I still think Mac has it all over PC.

    I read thru the data migration one below however wasn't sure of its applicability given it was from 09.
    Re: 2. there seems to be data I have yet to bring across. How important it is I don't know. What exactly it is I also am yet to find out. Will proceed with the downloading n stuff.
    Thank you for your help on this.

  • What is the best way to replace a cracked screen for the MacBook Pro?

    My MacBook Pro was accidentally droped and the screen was cracked.  Need to find out what is the most effecient way to replace the screen?

    Contact your nearest Authorized Apple Service Provider and ask them about the costs.
    MacBook Pro - Contact Support - Apple Support

  • What's the best way to read/write data from a file (preferabl​y a *.txt file)?

    As in the title.  l have revived a couple of old VIs to read and write three numbers and a 1D array of clusters to/from a *.txt file.  The functionality is not very user friendly, and it would also be useful if one could open the text files (manually - not through LabVIEW) and still be able to see/understand what was there.
    I was wondering if anyone would be able to come up with a more efficient and/or user friendly method (compatible with lv6.1) 
    James
    Never say "Oops." Always say "Ah, interesting!"
    Attachments:
    Read Spec.vi ‏110 KB
    Write Spec.vi ‏58 KB

    My primary goal is to have something that works and is easy and comprehensive to operate.  Generating a human-readable file is just a bonus but would be nice if it could be achieved.
    I enclose pictures of the initial file dialog (for both loading and saving the data - referred to as Spec(s) from hence forth), and of the front panel screen seen when  a) loading a spec and  b) saving a spec.  In the file dialog, you have to already know the exact string to input else you'll just be told the file doesn't exist (applies for both loading and saving).  When saving a spec, you cannot see any files previously saved, nor even any previous specs saved within the file.  This means that one can unwittingly overwrite specs without realising it.
    I'm not sure if I've explained this very well, but the current functionality means that far too much can go wrong.  Additionally, if you forget the file name, you'll have no way of knowing what it should be (the data files are stored on a 'locked' part of our network accessible only by Admin or through the LabVIEW executable
    Never say "Oops." Always say "Ah, interesting!"
    Attachments:
    File Dialog.JPG ‏23 KB
    Select The Required Test Spec.JPG ‏10 KB
    Name of specification.JPG ‏6 KB

  • What's the best way to replace iPod Nano 1st Generation?

    I have two iPod Nano 1st Generations. One from 2005 and one from 2006. The one from 2005 just works when it feels like it. Sometimes it works and most of the time it doesn't. And the one from 2006 recently exploded when it was charging. A silver bag (I'm assuming the battery) expanded and ripped the iPod apart breaking the plastic around the scroller.
    Should I use that replacement program (I heard it didn't work for some) or can I just bring them to an Apple Store to replace them?

    See if either qualifes under the 1G Nano recall.
    http://www.apple.com/support/ipodnano_replacement/
    B-rock

Maybe you are looking for

  • My iMac 24" killed my iPod Nano

    Recently my iMac froze while doing numerous things at once. It wasn't a normal kernel panic, as it didn't show the small grey box. I waited a while to see if whatever had caused the system to halt would resume, but nothing changed. I tried to Force Q

  • Server error message 504

    Why does my iCal icon keep jumping w/the error message Request for account "Yahoo" failed then server error message 504 and 502.  It happens about every 2 minutes! Help

  • Maximum length sound file in mms message i can receive?

    If someone sends me a sound / voice memo type thing in a text/mms message from a different make of mobile, whats the max length i can receive on my 3GS?

  • MERGE statement without INSERT clause....is possible...?

    Hi everybody... MERGE statement without UPDATE or INSERT clause is possible or not I want to select from one table and update in another table. So i dont want insert statement and i want to do it in single query....possible solutions are requested. T

  • PO Base Tables and Validation

    Hello All, I need to develop conversion interface of open purchase orders. Need help to know what are the base tables which are used for the same. Also Need to know what all validations needs to be done. I have identified a few. 1     PO Number alrea