Problem in deleting and renaming?

i have a text file in which i have to change some values in it.
so i tried using this code..
asciiFile = new File(FileName);
            TempFile = new File(asciiFile.getParent(), "Temp1.xml");
            BufferedReader buff = new BufferedReader(new FileReader(asciiFile));
            BufferedWriter bw = new BufferedWriter(new FileWriter(TempFile));
            for(String line = ""; (line = buff.readLine()) != null;)
                if(line.contains("<equation format=\"inline\">"))
                    for(int vv = 0; vv < ActualEquationToBePasted.size(); vv++)
                        String ff = line.replace(EquationToBeExceuted.elementAt(vv).toString(), ActualEquationToBePasted.elementAt(vv).toString());
                        line = ff;
                    bw.write(line);
                    bw.write("\n");
                  //  System.out.println(line);
                } else
                    bw.write(line);
                    bw.write("\n");
                  //  System.out.println(line);
            buff.close();
            bw.close();
           File org = new File(FileName);
         System.out.println(asciiFile.delete());
         TempFile.renameTo(org);Actually i created the temp file and writing the modified file. and i try to rename that file to the original filename b4 that i am deleting the orgn. file. but its not deleting. it is reutrning false. can anyoine help out in this.

works here...
import java.io.*;
public class FileDelRen {
       public static void main(String[] xyz){
              String fName = "file1.txt";
              String tName = "temp.tmp";
              File file = new File(fName);
              File temp = new File(file.getParent(),tName);
              try{
                  BufferedReader br = new BufferedReader(new FileReader(file));
                  BufferedWriter bw = new BufferedWriter(new FileWriter(temp));
                  String data = null;
                  while( (data = br.readLine()) != null ){
                     bw.write(data,0,data.length());
                  br.close();
                  bw.close();
                  br = null;
                  bw = null;
                  file.delete();
                  System.out.println( " File renamed : " + temp.renameTo(file));
              }catch(FileNotFoundException fnfe){
                                 fnfe.printStackTrace();
              }catch(IOException ioe){
                                 ioe.printStackTrace();
}btw, i added the br = null; and bw = null; to ensure there are not references to the File objects in question...
- MaxxDmg...
- ' He who never sleeps... '

Similar Messages

  • Open File dialog user can delete and rename files.

    Does any one know if there is a way to prevent a user from deleting and renaming files by right clicking on them in an Open File dialog box?

    Well, the problem is that this isn't a LV dialog box. It's the standard Windows file dialog box and this is the way they work in Windows.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Delete and Rename External User

    I'm trying to delete and rename EXTERNAL (foreign) users in GroupWise via the AdminObject API. I can create them no problem and I can change their attributes no problem (e.g. givenName, sn). However, when I try and delete or rename, the call succeeds, but the object is not deleted on a delete and not renamed on a rename.
    For a rename, I am assigning a new AccountID and then doing a commit. The call executes, but the account is not renamed.
    Is there something special about External Users I'm missing? I'm doing this in Visual Basic. Thanks.
    Matt

    I figured out what I was doing wrong on the delete. I was doing a commit after the delete! So I think I was basically re-adding the External User. So once I stopped that, I was able to delete External Users.
    But I still cannot figure out how to rename one. I was changing AccountID. That's really not what I want to do, I need to change the MailboxID, but that is read only. How can I rename an External User?
    Thanks.
    Matt

  • Delete and rename function module

    Hi,
    I have created a function module, but wanted to rename it afterwards.
    that was not possible, because I have got the message, that it´s locked in any transport requests.
    So I have copied the function and want to delete the old one now. But the same problem...
    I have removed the object entry on "function modules" in the request, but I still get the message, that
    it´s locked in the request.
    What can I do to delete and rename the functions?
    Thank you!

    hi ,
    GO to se03.
    in that you can see , search for objects in request /tasks.
    click that ,
    in the object selection screen
    in R3TR / FUGR  - 'Give that function group name'.
    you can get all the request , where that function group exists.
    Note down the requests.
    Then, go back in se03 itself.
    There u can see 'unlock objects'.
    give the transport numbers in that. It will unlock the function module.
    Hope , it vil solve it.
    Regards,
    sabari

  • My husband and I both have iPads and somehow when they were setup the both we're setup using the same email I'd address. When I go to delete and rename one iPad it says all info and pictures will be erased from my iPad. Is there a way to keep the info iPa

    My husband and I both have iPads and somehow when they were setup the both we're setup using the same email I'd address. When I go to delete and rename one iPad it says all info and pictures will be erased from my iPad. Is there a way to keep the info IPad when doing this?

    You can go to Settings/iCloud and delete the account, then create a new iCloud account.  You can still use the same account for the app store though.

  • How to delete and rename LSMW projects...

    Hello Experts,
    I can't seem to find a way on how to delete and rename my LSMW projects.I dont see any options on how
    to rename it.
    Thank you guys and take care!

    On the LSMW transaction start screen. Goto->Administration. Here you can select your project etc. and rename/delete/copy.

  • Problem of Delete and Overwrite XLS file on Application Server

    Hi Experts,
         I want to transfer file on application server using below code and try to delete after successfully transfer on application file to other location.
    I have problem during deleting file and overwrite file.
    DATA: G_S_FILE TYPE EPSFILNAM,
          G_S_DIR  TYPE EPSDIRNAM,
          G_T_FILE TYPE EPSFILNAM,
          G_T_DIR  TYPE EPSDIRNAM.
    DATA : DELFILE(60).
      G_S_FILE = '1400000051.XLS'.
      G_S_DIR  = '\\Dev\PO\'.
      G_T_FILE = '1400000051.XLS'.
      G_T_DIR  = '\\Dev\PO\bkup'.
      DELFILE = '\\Dev\PO\1400000051.XLS'.
      CALL METHOD CL_CTS_LANGUAGE_FILE_IO=>COPY_FILES_LOCAL
        EXPORTING
          IM_SOURCE_FILE           = G_S_FILE
          IM_SOURCE_DIRECTORY      = G_S_DIR
          IM_TARGET_FILE           = G_T_FILE
          IM_TARGET_DIRECTORY      = G_T_DIR
          IM_OVERWRITE_MODE        = 'S'
        EXCEPTIONS
          OPEN_INPUT_FILE_FAILED   = 1
          OPEN_OUTPUT_FILE_FAILED  = 2
          WRITE_BLOCK_FAILED       = 3
          READ_BLOCK_FAILED        = 4
          CLOSE_OUTPUT_FILE_FAILED = 5
          OTHERS                   = 6.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      OPEN DATASET DELFILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      IF SY-SUBRC = 0.
        DELETE DATASET DELFILE.
      ELSE.
        WRITE / 'File not found'.
      ENDIF.
    Thanks,
    Himanshu Patel.

    Write a Java program using Apache POI that reads in a tab delimited file and outputs an xls file (in what they call Horrible Spread Sheet Format. Create your tab delimited file and then run your Java program using appropriate OS commands.
    Jelena Perfiljeva wrote:
    In all honesty, I find it hard to believe other application can't accept any other format. It's actually seems rather unreasonable to expect an ERP system to create a file in an outdated format of a desktop software. Even Excel itself can open many formats, so this just doesn't make any sense.
    This.
    Unless you can explain exactly why the destination must be xls and no other format is acceptable, I'm going to close the thread. What is this third party tool? Why can it only read the obsolete xls file format.
    I'm going through this thread and rejecting all the responses that attempt a solution that isn't xls.
    I'm surprised that the OP thought that simply saving with an xls file extension would cause some magic to happen and produce an actual Excel file.

  • Deleting and Renaming

    Apologies if this is obvious, but I can't find the answer. If say you've saved something in pages as a letter with a title say John, how does one delete it please? I can delete the contents, leaving me a blank sheet still called John, but can't see either how to delete the sheet altogether (preferable) or even how to rename it. It's saved in a folder, basically used for letters, but I don't just want to go on filling this up for years and years with out of date correspondence. No doubt this is easy, but as a newcomer I just can't see it. I've tried dragging it to trash, doesn't work, and delete and delete page only deletes the content. Any help much appreciated. Thanks

    ziggy
    Have you ever used a computer before? If so what kind?
    You really should do an introduction to the Mac tutorial:
    http://www.apple.com/support/mac101/
    A computer is like a photocopier, when you open a file it is like you have made a copy of what is on your Hard Drive inside the computer.
    You can alter that copy and save it with another name, that makes another copy with different content.
    You will see it in Finder (your Desktop) the Window you said had the little House (this represents all your stuff in the computer).
    If it has a different name it becomes a *new file* or document.
    If you save it with exactly the *same name* in the *same spot* it will replace what was there before and the saved file becomes the only copy with that name. It warns you that will happen. Saving when you have opened an existing document does exactly what it says, it saves what you have done to the existing document permanently changing it
    A template is like a letterhead or pre-printed copy of a document but one where you can actually change the text or pictures inside it. It doesn't have a name till you give it one. This is so you won't replace the existing file and have to do all the prepared work all over next time.
    You do not get rid of a document by opening it and removing all the contents, anymore than you get rid of a piece of paper by rubbing out what you wrote on it. To get rid of both the real piece of paper and the computer file you have to toss it in the trash and have the trash emptied.
    You do that on the computer by going back into Finder which is where you see all the icons and windows with lists of files in windows. Then clicking on the icon or name of the file you want to getr rid of and dragging into the trash basket on your Dock on the bottom right of your computer screen.
    You do not do any of the trashing inside Pages, you have to do it in Finder.
    You really do need to do the Introductory course above, this is all very basic.
    Peter

  • PSE5 organizer tracking deleted and renamed folders and removing orphan thumbnails

    If files are deleted or renamed within a folder that's being watched by organizer, the changes made through explorer or any other program don't seem to ever get reflected in Organizer. For example, I deleted an entire folder of junk photos through Windows. They still show in Organizer. How do I tell Organizer to re-scan the folder and remove orphan thumbnails from the catalog? The only thing I've been able to do at this point is to highlight them all and delete them. That's not bad for a single folder, but is a pain when I've done a lot of renaming, reorganizing, and creation and deletion of folders and subfolders under the watched folder.
    I've used a program called Thumbs Plus for years, and it has an option "remove orphans" that you can do globally, or on a folder and its subfolders. I'm wondering if there's something similar in PSE.

    Yes, I realize that in an "ideal" world we could do absolutely all of our organizing in "organizer" but I just can't see that becoming a reality. We have different users on this computer and there are certainly going to be times when we're already working in another program, including Windows Explorer. One would think that if Organizer is monitoring a folder it would detect all changes, or at least have a manual "rescan folder" or "remove option of some sort to help get the real files back in sync with the catalog. Hmmm. I'm still using eval mode and not sure that I like this part! Perhaps the next version will do better in this regard.

  • Deleting and renaming RandomAccessFiles

    hello,
    i am creating two files f1.txt and f2.txt using RandomAccessFile class in 'rw' mode. and then, i am copying the contents of f1.txt to f2.txt. Now, i need to delete f1.txt and rename f2.txt to f1.txt. But, i have no idea of how to rename and delete those files. plz help me out of this.
    thanks

    Check out the methods of java.io.File

  • Problem with deleting and recreating domain

    Dear All
    I am compltely confused to delete and purge domain with commadmin below you can see output from.
    ./msuserpurge -v -dmycom-int.com -g0 command.
    Domain Name : mydomain.com
    mailDomainStatus: active
    inetDomainStatus: deleted
    User Name mailUser inetUser Modified Time Action
    total: 0 | deleted: 0 | purged: 0 | pending: 0 | error: 0
    when I try to purge the this domain with commadmin it generate the nonleaf error.
    [root@beagle1 bin]# ./commadmin domain purge -dmydomain.com
    Enter login ID: admin
    Enter login password: adminadmin
    FAIL
    Unable to remove entry.::LDAP Error:NOT_ALLOWED_ON_NONLEAF domain => mydomain.com
    I am really confused, I don't know how I have to find out what is inside this domain which is not empty to be deleted.
    any help would be appreciated.
    Best regards
    Mo

    Didn't I just respond to this same question?
    your error message claims that there is something in your domain, so it can't remove it.
    Usually, it's a user. There's no way I can tell what's in there. You can use the Directory Console to see, though.

  • Deleting and Renaming takes way too long

    I have been using Bridge CS3 on my desktop (win xp, 3gb ram) for quite some time with no major problems that I couldn't figure out. Recently, I bought a laptop with Vista and 3gigs of ram. I pretty much only use this laptop for bridge and ACR and some photoshop actions. When I started using Bridge I noticed that it was actually a little bit faster than my desktop when opening folders of images and using the quick develop and ratings and labels.
    However, once I tried to delete a group of images or batch rename a group of images I might as well find something else to do for at least 12 hours before I check back on the progress.
    So as a test I ran a group of 700 images through the batch rename on my desktop and it took about 5 or 6 minutes to rename and then reload the thumbnails. (even this seems a little slow to me, but oh well, i like bridge anyway) At the same time I ran the same amount of images through the batch rename on my laptop. This was about an hour and a half ago and the progress bar in the "Renaming Files" pop-up window is all the way to the left and hasn't moved a millimeter to the right.
    Anyone know what's going on?
    thanks, Ross

    Curt-
    Thanks for the reply!
    Quick thumbnails: Yes, always
    Video card: NVIDIA GeForce 8400M GT
    The performance of the laptop has been great. It is a sony vaio that I bought 2 months ago and it has been very capable with CS3 photoshop, bridge and ACR. I load in thousands of raw files, cull them down to 600-800, apply quick develop settings with camera raw, and then batch all 800 through a fairly intense photoshop action. All of this runs great except when I want to rename or delete in Bridge. A little earlier I finally shut down bridge after letting it rename images for 3 hours and it had only renamed 7 files out of 700. (And I'm just trying to rename to Name_0001)
    If you think I should run a performance check, I will. I'm just not familiar enough with Vista yet to know how.
    ross.james
    RossJamesPhotography.com

  • E71 delete and renaming email accounts

    Hi all,
    Having had a few problems setting up my email account, I now have 3 different accounts, of which only 1 works.
    How do I delete the unwanted accounts and how do I delete the remaining one to something more sensible?
    Many thanks
    MG

    See Here
    iCloud Help
    http://help.apple.com/icloud/?lang=en

  • Calendar deleted and renamed "Hi". Have I been hacked?

    Have I been hacked?  One of my private calendars that is backed up on my icloud was renamed "Hi" and all the events were deleted. 

    simply telling us you can't access your email really tells us nothing.  more details please.

  • Today, I agreed to an automatic upgrade and now Firefox starts to open but stops. It says 3.6.11 and I have the same problem after deleting and reinstalling.

    It bounces in Dock and stops, it never opens. Opening from .app opens in Dock and immediately disappears.

    I downgraded to 3.6.10 and had the same problem. Downgrading to 3.6.9 resolved problem. Will retry upgrading later.
    Maybe unrelated but 3.6.9 recommended I upgraded Adobe Flash Player from 10.1 r53 to 10.1 r85, which I did

Maybe you are looking for

  • Why are my movies not showing on my Mac Book, which is the computer that I used to purchase the movie, but showing on my IMAC at home...I am currently deployed.

    why are my movies not showing on my Mac Book, which is the computer that I used to purchase the movie, but showing on my IMAC at home...I am currently deployed so this ***** a bit. Also how do I keep this incedent from happending in the future?

  • Repeater demo question: how to filter by name?

    Hello, I was looking at the repeater demo in the JSF beta distribution for some help with a problem I'm having. For example, how would one modify the demo so that #{RepeaterBean.customers} only returns those customers who have a specific name? My tho

  • DB ISSUE: DAE.DB_READ_FAILED

    Hi everyone I am experiencing an issue in terms of writing to OIM through thortec API. It should be said that I am experiencing this issue in production, on a system, that have been running smoothly for over half a year. Setup: BEA Weblogic 8.1 SP6 O

  • HTMLLoader and Scrollbars

    I've been following the lynda.com AIR for Flash Devs tutorial. It shows how to add the Scrollbar Class to an HTMLLoader. Is it just me, or is Adobe's Scrollbar a rather odd implementation? I mean it works, but, for instance, the scroll handle you gra

  • Final Cut X Won't Let Me Use It

    I can't get into final cut pro x.  I open it, everything loads, and everything LOOKS fine. but as soon as I click on anything, the whole program freezes up and i'm stairing at a beachball.  I have restarted my computer, i've done a hard re-boot, i do