Trouble opening and editing a text file

As part of a larger program, I am trying to open a text file(actually a .py file) and edit a specific line in the file. However, all that I can get the program to do is read the file, but not edit the line. Here is my code. Any help would be greatly appreciated!!
    private void editPythonScript() throws FileNotFoundException, IOException{
        File temp = new File("Temp");
        FileReader fr = new FileReader(path + "\\" + script);
        BufferedReader br = new BufferedReader(fr);
        FileWriter fw = new FileWriter(path + "\\" + temp);
        BufferedWriter bw = new BufferedWriter(fw);
        PrintWriter pw = new PrintWriter(bw);
        String line;
        line = br.readLine();       
        while(line != null){
            if (line == "oids = [ ]"){
                System.out.println(line);
                line = "oids = [ " + oids + " ]";
                System.out.println(line);
            pw.println(line);
            line = br.readLine();
        br.close();    
        fr.close();
        pw.close();
        bw.close();
        fw.close();
        br = new BufferedReader(new FileReader(path + "\\" + temp));
        pw = new PrintWriter(new BufferedWriter(new FileWriter(path+"\\"+script)));
        line = br.readLine();       
        while(line != null){
            pw.println(line);
            line = br.readLine();
        br.close();
        pw.close();
    }

Awesome! Thanks. I knew it had to be something simple like that!!!

Similar Messages

  • Open and edit a .car File via VBA?

    Post Author: andy30
    CA Forum: Other
    Hello,
    i want to open and edit and import a  *.car  File from an Excel Macro. Is that possible? I have the olap intelligence Add in for excel, but there a only functions to open dialog boxes (ui_wrappers).
    thank you for your help.
    Andy

    Photoshop reads and writes PSB files.

  • Is there an Application that opens  and edits mpeg movie files

    Is there an Application that opens and edits mpeg movie files

    At what level do you want to do video editing?  There are a number of apps that will work with mpeg files available in the App Store, just search on mpeg.  If you want to do heavy duty video editing and work there is always Final Cut Pro X...but that costs $299.99 US...and will do anything and everything.

  • Open and read from text file into a text box for Windows Store

    I wish to open and read from a text file into a text box in C# for the Windows Store using VS Express 2012 for Windows 8.
    Can anyone point me to sample code and tutorials specifically for Windows Store using C#.
    Is it possible to add a Text file in Windows Store. This option only seems to be available in Visual C#.
    Thanks
    Wendel

    This is a simple sample for Read/Load Text file from IsolateStorage and Read file from InstalledLocation (this folder only can be read)
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Windows.Storage;
    using System.IO;
    namespace TextFileDemo
    public class TextFileHelper
    async public static Task<bool> SaveTextFileToIsolateStorageAsync(string filename, string data)
    byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(data);
    StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
    var file = await local.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
    try
    using (var s = await file.OpenStreamForWriteAsync())
    s.Write(fileBytes, 0, fileBytes.Length);
    return true;
    catch
    return false;
    async public static Task<string> LoadTextFileFormIsolateStorageAsync(string filename)
    StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
    string returnvalue = string.Empty;
    try
    var file = await local.OpenStreamForReadAsync(filename);
    using (StreamReader streamReader = new StreamReader(file))
    returnvalue = streamReader.ReadToEnd();
    catch (Exception ex)
    // do somthing when exception
    return returnvalue;
    async public static Task<string> LoadTextFileFormInstalledLocationAsync(string filename)
    StorageFolder local = Windows.ApplicationModel.Package.Current.InstalledLocation;
    string returnvalue = string.Empty;
    try
    var file = await local.OpenStreamForReadAsync(filename);
    using (StreamReader streamReader = new StreamReader(file))
    returnvalue = streamReader.ReadToEnd();
    catch (Exception ex)
    // do somthing when exception
    return returnvalue;
    show how to use it as below
    async private void Button_Click(object sender, RoutedEventArgs e)
    string txt =await TextFileHelper.LoadTextFileFormInstalledLocationAsync("TextFile1.txt");
    Debug.WriteLine(txt);
    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

  • How to open and edit a VBscript file?

    Hi,
    I'm fairly proficient with Dreamweaver CS3.  However, i'm finding one aspect of CS4 to be baffling to the extreme.
    I work with VBScript files.  When I open up a script file that includes other script files, the name of the parent file is seen on a tab (with an x to the right of it).  Below it are tabs for all of the files that are included (via an include statement in the code).  That's nice.
    When I click on one of the included files I see that file show up in my window.  However, I am unable at this point to get back to the file that included this one; i.e., the master file that is still above the other files.
    If I click on the tab for the master file, I don't see the contents of this file.  If I click on the small white paper icon (with the top right corner folded) on the left navigation bar, I see the name of the master file.  Selecting it still doesn't fill my editor window with the master file.
    There is a little symbol on the right side of the tabs for the included files.  (It looks like >>, except the arrows face down.)  This has the list of all of the files that I have open, minus the master file.
    It is very hard to believe that Dreamweaver would make CS4 this hard to use.  Unfortunately, I have no idea how to get the master file back in the editor window after I have clicked on one of the files it includes.  Can anyone point me in the right direction?  thanks.

    Hi,
    Use JDeveloper to import the mwp project .In Jdeveloper,File->Import->ToplinkWorkbench->Select the .mwp file and can work from JDeveloper in editing the tlmap.xml and session.xml.
    Regards,
    P.Vinay Kumar

  • Can you recommend an iPad app to open and edit MS Excel files?

    Hi,
    I need an iPad app that would enable me to do the following with a MS Excel file:
    Import the file from Dropbox
    Edit and save the file
    Export the edited file back to Dropbox
    Can anyone recommend an app that can do the above?
    Thanks
    Daniel

    Thanks for the feedback. I have read the reviews of both apps and they are not that great. The DropBox functionality seems to work finenwith both apps.
    I want to use the spreadsheet on both my iPad and PC. The reviews of both apps mention that some reformatting of the .xls file can occur when saving it in the app. Have any of you experienced this? I will only be using the app for simple .xls files with normal/simple formulas. Nothing complicated at all. I might use it for Word files, but I have no use for PowerPoint. The only time I might use the PowerPoint functionality is if I happen to receive such a file via email. I'm still using Office 2003 with no intention to upgrade anytime soon as it is just fine for my needs.
    The QuickOffice Pro HD app is currently on sale for $11.99 whereas the Documents to Go Premium app that supports DropBox is $16.99. D2G is an universal app and QOP is not.
    Any suggestions on which app is the better one would be appreciated.
    Regards
    Daniel

  • Opening and Editing SWF files

    Does anyone know if there is a way to open and edit a SWF file.

    No, you have to have the fla file to edit.  You can purchase/use a decompiler to convert the swf into an fla file, but I have no experience or recommendations to offer regarding that... only hear-say--towards the negative side

  • How can I open and edit files that were developed and published by ftp to my host on my old macbook, which I can no longer access.

    How can I open and edit files that were developed and published via ftp to my host on my old macbook, which I can no longer access. The HD containing the files cannot be accessed. I want to be able to download the published files to be edited in iweb?

    You CAN'T download published files and then edit them in iWeb because iWeb can't open them - it has no import facility so is unable to open any html or css files - a previously published site.
    You can download these files yes, but you'll need to use them as a guide or to cut and paste text from there whilst you re-build your site in iWeb.
    The only other way is to download the files and then open them with an html editor such as TextWrangler or use one of the other web design programmes out there that is capable of importing html and css such as Dreamweaver of Flux 4.
    These are your only alternatives as iWeb can't import and if you want to continue to use iWeb, then you'll have to re-build your site from scratch.  If you do just remember to back up your domain.sites file this time around - it is found under your User/Library/Applicaion Support/iWeb/domain.sites.

  • How to open and edit CRP files?

    Hi,
    at my workplace I see the following folders:
    C:\Program Files\Novell\ZENworks\Asset Management\bin\UsageLogs
    In this folder I see secret files like: 20090115.CRP and 20090115-web.CRP
    Each days ZenWorks create this 2 files.
    How can I open and edit it? Which software have to install at home for check it? I'm interested in very much what contain this files...
    Thanks,
    Gery

    Those files would be software usage metering files. There is no software to the best of my knowledge that opens those files. They are loaded automatically by the collection server into the database.

  • How to open and edit a TopLink .mwp file?

    I can not open the toplink_mappings.mwp file using JDeveloper tool.
    How to open and edit a TopLink .mwp file?
    Thank you

    Hi,
    Use JDeveloper to import the mwp project .In Jdeveloper,File->Import->ToplinkWorkbench->Select the .mwp file and can work from JDeveloper in editing the tlmap.xml and session.xml.
    Regards,
    P.Vinay Kumar

  • How open and edit the coherence.xml file?

    How can I open and edit the coherence.xml file?
    I cannot find the coherence.xml file in the coherence.jar package.
    Thank you,
    June

    If you are intent on changing the coherence.xml file, then you could use the JAR command (that comes with Java) to extract the coherence.xml file from coherence.jar and the later repackage the coherence.jar file using the udpated coherence.xml file, e.g.:
    C:\java\opt\coherence-331\lib>jar -xvf coherence.jar tangosol-coherence.xmlextracted: tangosol-coherence.xml>
    Instead of using JAR, on Windows you can associate the .JAR, .WAR and .EAR extensions with WinZip and use it to access / modify the contents of JAR files.
    However, the suggested approach is as follows, and does not include any changes to the tangosol.jar file:
    The tangosol-coherence-override-dev.xml file can be found in the coherence.jar file. After editing this file (in this case to define a unique value for the port system-property value for the multicast listener), save the file and add it to the server's classpath. When the server is executed, the values in the tangosol-coherence-override-dev.xml file will override any corresponding settings in the tangosol-coherence.xml file.Peace,
    Cameron Purdy | Oracle Coherence

  • Is there a way to open and edit my iMovie HD files with iMovie '09 and later versions?

    I am getting ready to update an older iMac from Tiger to Mountain Lion. (Long overdue, I know) I have several files that I created using iMovie HD. After I update, will the new versions of iMovie be able to open and edit my iMovie HD files?

    I don't think that iMovie 11 is backwards compatible with iMovie HD 6.
    If you still have the install disks for iMovie Hd 6 (iLife 6) you can keep it alongside the newer version:
    Happily this is easily achieved, but it has to be done backwards.
    Delete iMovie 11 (just drag it to the trash). Now install iMovie 6 from the iLife 6 install disks. Update it to iMovie 6.0.3.
    Now re-install iMovie 11. This automatically moves iMovie 6 into a folder it creates in your Applications folder called iMovie Previous Version.
    Then reinstall iMovie 11.
    iMovie 6 works great with iDVD 7.
    Now you have them both, and you can have both in the Dock as well.
    Alternatively you could try this method, suggested by poster Uitech:
    Open a terminal and type "touch /Library/Preferences/com.apple.iLife011.plist"
    (No quotes)
    Install iMovieHD6 from the iLife 6 install disk.
    This works with both Leopard and Snow Leopard Macs.

  • Can i open and edit nikon d810 raw files in lightroom 4.4

    can i open and edit nikon d810 raw files in lightroom 4.4

    No. Lightroom 4.x will never be able to open Raw files from the D810.
    D810 support has only just been added to the RC version of Camera Raw 8.6. It is never retrospectively added into older versions.
    Adobe Photoshop Camera Raw 8.6 RC for CC and CC 2014 Release Candidate | digital camera raw file support - Adobe Labs
    Adobe will probably add D810 support to the next version of Lightroom.
    Either way you'll have to upgrade to Lightroom 5 to be able to open D810 Raw files in Lightroom.

  • I have office 2004. what do i have to buy, download, install to open and edit pptx, docx and xlsx files?

    i have office 2004. what do i have to buy, download, install to open and edit pptx, docx and xlsx files?

    Visit  Microsoft  at this site download converter.Install drag XML file and it creates a standard .doc, .xls or .ppt copy on your desktop.
    Its free and works a charm.
    NO need to spend a penny/cent
    http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6B9238E1-CF69-48C4-B F2D-C4A8ACEEE520

  • Opening and editing .pub files

    Can anybody tell me if there is any way to open and edit .pub files without converting them into PDF's???

    Hi, not that I can find, but besides PDF, perhaps as MS .doc using this method?
    http://www.maketecheasier.com/open-mark-up-pub-file-on-mac/2011/04/11

Maybe you are looking for

  • Installing SAP R/3 4.6C SR 2 on Oracle 10.2 On HP-UX 11.31 Platform

    Dear Expert, I want to migrate our old SAP system 4.6C from HP-UX 11.31 and using Oracle 10g. The export process has be done successfully. When I tried to install the central instance, the problem occur. After run command ./R3SETUP -f CENTRAL.R3S in

  • Unable to view some iviews in the portal

    Hi, We are unable to view some of the iviews in the portal. For example i go to System Administration>System Configuration> I should see portal content and the list of systems etc but i get a Page Cannot Be Displayed error. But we are able to view th

  • Conditional Build Tags + Image Map + Popup Doesn't Work

    For RH build X.5.0.2, I have images in some topics and a conditional build tag is applied to those images. The images have image maps drawn on them and those image maps launch popup topics. Everything worked fine until I added the conditional build t

  • Can I control a computer through a phone line instead of the internet?

    I have used a program called procontrol in the past which allows me to adjust sensor set points and get readings over a phone modem. How can I adapt this to labview. I am currently using logmein to control the computer, but the cost for internet is m

  • Problem with running Premiere Elements 12 for the first time.

    I have just purchased a download version of Premiere Elements 12.0 and have installed it on my PC running on Windows 7 (64 bit). On first running Elements, however, the program gets stuck on loading "mveH264Exporter.prm" and proceeds no further. I've