Delete and renameto not working in java

guys, i have written a java program that reads file1 into temp file and finally writes into another file. program is working fine with no errors, it even reported that the file is deleted. But actually the file was not deleted and renameto was never successful. could you guys see any problem with file definetion so that delete is not successful. please see code from 6th line from bottm.
public class Mergewrs {public static void main (String[] args) throws IOException {
/* Creates a new instance of mergewrsFile */
     /* Making sure an argument is specified */
     if(args.length > 0)
          String line           = null;
          String policyflag      = null;
          int addCnt          = 0;
          File mergein = new File("c:\\javat\\mergein.dat");
          /* Specifiying input file to be used */
          BufferedReader  inFile  = new BufferedReader(new FileReader(mergein));
          line = inFile.readLine();
          /* Read all lines in the wrsfile specified */
          while(line != null)
               System.out.println("Process1: ");
               policyflag      = line.substring(0,1);
               // Reads input record from 2 thru 1025
               String actionIndicator = new String();
               if(policyflag != null && policyflag.equalsIgnoreCase("A"))
                    { actionIndicator = "A";
                      addCnt = addCnt+1;
                      process(actionIndicator, line);
               catch(IOException e)
                    {System.err.println("File input error");}
               line = inFile.readLine();
          } //while ends
     } //if ends
public static void process(String actionIndicator, String line) throws IOException
     String line1 = null;
     String templine = null;
     String policyId = null;
     File policyOutfile = new File("c:\\javat\\mergeout.dat");
     File policyOutfileold = new File("c:\\javat\\mergeoutold.dat");
     BufferedReader  policyOut  = new BufferedReader(new FileReader(policyOutfile));
     File tempfile = new File("c:\\javat\\tempfile.dat");
     BufferedWriter tempout = new BufferedWriter(new FileWriter(tempfile));
     line1 = policyOut.readLine();
     try{
          policyId =line1.substring(150,165);
          while(line1 != null)
          {     policyId =line1.substring(150,165);
               try
                    if(policyId.equals(line.substring(151,166)))
                         { templine =line1.substring(0,151);
                    else { templine=line1;}
                    tempout.write(templine);
                    tempout.newLine();
                    line1 = policyOut.readLine();
               catch (Exception e) {System.err.println("File exception h");}
          } //while ends
          try { tempout.close(); }
          catch (Exception e) { e.printStackTrace();}
          try { policyOut.close(); }
          catch (Exception e) { e.printStackTrace();}
          try
               if(policyOutfile.exists())
                    policyOutfile.delete();
                    tempfile.renameTo(policyOutfile);
          catch (Exception e) {System.out.println("error"); }
}

guys, i have written a java program that reads file1
into temp file and finally writes into another file.
program is working fine with no errors, it even
reported that the file is deleted. But actually the
file was not deleted and renameto was never
successful. could you guys see any problem with file
definetion so that delete is not successful. please
see code from 6th line from bottm.Since you don't actually do anything with the return value how do you know it was successful?

Similar Messages

  • RenameTo.(), Delete(), and mkrdir() not working????

    Hello Every Body
    i was just trying to make rename, delete, or even mkdir for files but for some resoan the value returned is FALSE??
    here are some peice of my code
    File f = new File(path+"\newfolder");
         out.print(f.mkdir());
    File f = new File(path+"\newfolder");
    out.print(f.delete());
    File f = new File(path)
    String newname = "new.txt";
    out.print(f.renameTo(new File(newname)));
    path: is not the same path for (Apache Path) is another path like(/usr2/httpd/jspapps/fm2-1);
    NOTE: im using Linux RedHat, and Mozila Firefox v1.0

    same problem
    but i think the problem is about the Permission of files
    i have 777 permission (full permission to write, read, execute) of the parent folder and files
    but not for all the parents folders:-
    this is the full path
    /usr2/httpd/jspapps/ashraf
    i have the -777- premission of "ashraf" folder only....???!!!!

  • Simple insert, delete and update not working after oracle 10g installation

    Hello,
    I made a new installation of Oracle 10g (10.2.0.1.0) and created a schema . Now i try to insert or update data using simple queries, but unfortunately nothing happens. I tried inserting or updating data even via sqlplus, but unfortunately the same result. Query takes infinite time to end, so i had to manually end it every time... No errors... No warnings... but takes long time... I have given all the required permissions to the schema but the same result. Can somebody help me figure out the problem?
    Tried creating a new table and the insert and delete are working fine... think the problem is with this table... Imported the rows of the table from another online database. I dont understand how this might be a problem.
    Edited by: user13333704 on Mar 15, 2011 1:26 AM

    However how do you generate awr reports and how to find the session wait?TO generate the AWR report
    sql> ?/rdbms/admin/awrrpt
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/autostat.htm#BABDHAGF
    The event column in v$session , in v$active_session_wait will show you the session wait event.What the session was actually waiting for.
    HTH
    Anand

  • The keyboard for my iMac 9, 1 got wet and is not working correctlly. Delete,return, and some other keys not functioning. In all caps including numerals. I've left it to dry for a few days but still will not work. Computer now in Safe boot mode and I c

    The keyboard for my iMac 9, got wet and is not working correctly. Delete ,return, and some other keys not functioning. In all caps including numerals. I've left it to dry for a few days but still will not work. Computer now in Safe boot mode and I can't login due to all caps and numbers being symbols. Is there anything I can do?

    Buy a replacement keyboard. They're only $50-65 USD.
    27" i7 iMac (Mid 2011) refurb, OS X Yo (10.10), Mavs, ML & SL, G4 450 MP w/10.5 & 9.2.2

  • Java applet works in windows and does not work in linux

    Hello, guys!
    I'm working with site which is located in vpn network at work.
    I use browsers firefox 3 and opera.
    When I want to open java applet using firefox or opera at first everything is fine then on the last stage of loading(judging by progress bar) applet hangs(progress bar hangs) and when I reload page firefox shows in the bottom bar: applet <applet's name> bail.
    In windows everything works both in ie6 and firefox 3.
    On both environments I have the jre 6 installed.
    please help!

    Ok, I installed ies4linux and jre 1.5.16. I can work with that but when I start applet screen goes black and window frames dissapear.
    To solve this problem(feature?) I disabled DirectX-based acceleration for Java 2D but that works for javacpl.exe and does not work for my applet.

  • Hi all, Since I updated to Mavericks I am having trouble with Safari showing all the buttons/clickable options, but they are gray and will not work. Specifically, the Trash Can/Delete and the "Move to" folder button simply do not work. Any ideas?

    Hi all, Since I updated to Mavericks I am having trouble with Safari showing all the buttons/clickable options, but they are gray and will not work. Specifically, the Trash Can/Delete and the "Move to" folder button simply do not work. Any ideas?

    Please post a screenshot that shows what you mean. Be careful not to include any private information.
    Start a reply to this message. Click the camera icon in the toolbar of the editing window and select the image file to upload it. You can also include text in the reply.

  • Delete operation is not working to delete selected row from ADF table

    Hi All,
    We are working on jdev 11.1.1.5.3. We have one ADF table as shown below. My requirement is to delete a selected row from table, but it is deleting the first row only.
    <af:table value="#{bindings.EventCalendarVO.collectionModel}" var="row"
    rows="#{bindings.EventCalendarVO.rangeSize}"
    emptyText="#{bindings.EventCalendarVO.viewable ? applcoreBundle.TABLE_EMPTY_TEXT_NO_ROWS_YET : applcoreBundle.TABLE_EMPTY_TEXT_ACCESS_DENIED}"
    fetchSize="#{bindings.EventCalendarVO.rangeSize}"
    rowBandingInterval="0"
    selectedRowKeys="#{bindings.EventCalendarVO.collectionModel.selectedRow}"
    selectionListener="#{bindings.EventCalendarVO.collectionModel.makeCurrent}"
    rowSelection="single" id="t2" partialTriggers="::ctb1 ::ctb3"
    >
    To perform delete operation i have one delete button.
    <af:commandToolbarButton
    text="Delete"
    disabled="#{!bindings.Delete.enabled}"
    id="ctb3" accessKey="d"
    actionListener="#{AddNewEventBean. *deleteCurrentRow* }"/>
    As normal delete operation is not working i am using programatic approach from bean method. This approach works with jdev 11.1.1.5.0 but fails on ver 11.1.1.5.3
    public void deleteCurrentRow (ActionEvent actionEvent) *{*               DCBindingContainer bindings =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding dcItteratorBindings =
    bindings.findIteratorBinding("EventCalendarVOIterator");
    // Get an object representing the table and what may be selected within it
    ViewObject eventCalVO = dcItteratorBindings.getViewObject();
    // Remove selected row
    eventCalVO.removeCurrentRow();
    it is removing first row from table still. Main problem is not giving the selected row as current row. Any one point out where is the mistake?
    We have tried the below code as well in deleteCurrentRow() method
    RowKeySet rowKeySet = (RowKeySet)this.getT1().getSelectedRowKeys();
    CollectionModel cm = (CollectionModel)this.getT1().ggetValue();
    for (Object facesTreeRowKey : rowKeySet) {
    cm.setRowKey(facesTreeRowKey);
    JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)cm.getRowData();
    rowData.getRow().remove();
    The same behavior still.
    Thanks in advance.
    Rechin
    Edited by: 900997 on Mar 7, 2012 3:56 AM
    Edited by: 900997 on Mar 7, 2012 4:01 AM
    Edited by: 900997 on Mar 7, 2012 4:03 AM

    JDev 11.1.1.5.3 sounds like you are using oracle apps as this not a normal jdev version.
    as it works in 11.1.1.5.0 you probably hit a bug which you should file with support.oracle.com...
    Somehow you get the first row instead of the current row (i guess). You should debug your code and make sure you get the current selected row in your bean code and not the first row.
    This might be a problem with the bean scope too. Do you have the button (or table) inside a region? Wich scope does the bean have?
    Anyway you can try to remove the iterator row you get
    public void deleteCurrentRow (ActionEvent actionEvent) { DCBindingContainer bindings =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding dcItteratorBindings =
    bindings.findIteratorBinding("EventCalendarVOIterator");
    dcItteratorBindings.removeCurrentRow();Timo

  • Applets not working with Java 1.7.0_51 in MII 14.0 SP4 Patch 5

    Hi,
    I'm currently evaluating the migration of our MII 12.0 developments to MII 14.
    But I'm running in several issues just trying to use simple things like a SQL query template with an iGrid Display template in test mode.
    Used versions are: MII 14.0 SP4 Patch 5 and on client side the latest Mozilla Firefox with Java 1.7.0_51
    At first I always get a java security warning when the applet is being loaded about unsigned applications.
    At second the applet itself is not running. It always shows "No data available" and the java console shows the following errors (iResult is the id of the applet):
    iResult [ERROR] - Couldn't set query template: No Query Defined
    iResult [ERROR] - Couldn't set display template: null
    iResult [ERROR] - Couldn't set display template: null
    Is this perhaps a general problem, that the MII applets are not working with Java 1.7.x versions?
    If I call the same MII page from a client with Java 1.6.x it is working without errors.
    Do you have some suggestions for me?
    Regards Timo

    please clear your JAVA Cache. that should solve the JRE issue. thanks

  • Delete Statement is not working correctly

    Hello,
    The following delete statement is not working correctly.
    If I press delete it will delete everything in the category table
    I don't know whats wrong with it.
    ----delete row from category if there is not infrastructure to support------
    IF :P12_DFCY_SEQNO4 IS NOT NULL AND :P12_DFCY_CATG_C = '7' THEN
    DELETE FROM DFCY_CATG
    WHERE NOT EXISTS(SELECT I.DFCY_SEQNO
    FROM DFCY_CATG C, DFCY_CATG_INFRSTRCTR I
    WHERE C.DFCY_SEQNO = I.DFCY_SEQNO
    AND :P12_DFCY_SEQNO4 = I.DFCY_SEQNO);
    end if;
    Thanks
    Mary

    Hi,
    IF :P12_DFCY_SEQNO4 IS NOT NULL AND :P12_DFCY_CATG_C = '7' THEN
    DELETE FROM DFCY_CATG
    WHERE NOT EXISTS(SELECT I.DFCY_SEQNO
    FROM DFCY_CATG C, DFCY_CATG_INFRSTRCTR I
    WHERE C.DFCY_SEQNO = I.DFCY_SEQNO
    AND :P12_DFCY_SEQNO4 = I.DFCY_SEQNO);
    end if;So, if P12_DFCY_SEQNO4 does not exist, then I would expect all records to be deleted because the NOT EXISTS() function would just return TRUE for every record on the table. Somewhere in the statement, I would expect to see something that links between the table being deleted from and the NOT EXISTS() data or, perhaps, using the P12_DFCY_CATG_C value as a filter?
    Andy

  • Delete statement is not working.

    Hi,
    find the code. Here the delete statement is not working and i am getting sy-subrc = 4. although ,
    xe1edp10-idnkd = 34596 and dint_edidd -sdata = 34596.
    please help me ...
    loop at dekek_x.
    loop at dint_edidd where segnam = 'E1EDP10'.
    if dekek_x-stpin = 1 .
    CLEAR xe1edp10.
      MOVE dint_edidd-sdata TO xe1edp10.
    delete dint_edidd where sdata = xe1edp10-idnkd.
    endif.
    endloop.

    1st thing..
    i tried this :
    tables: edidd, e1edp10.
    edidd-sdata = '315934 EA 017'.
    WRITE edidd-sdata.
    move edidd-sdata to e1edp10.
    IF edidd-sdata = e1edp10-idnkd.
    WRITE: e1edp10-idnkd.
    else.
      WRITE: 'nothing'.
    ENDIF.
    output
    >315934 EA 017
    >315934 EA 017
    2nd thing,.
    your loop inside loop doesnt make any sense as they are not related any where.
    3rd thing:
    the fields are not type compatible.. this might be the reason for wrong delete statement..
    and 1 more clarification:
    TABLES: edidd, e1edp10.
    DATA :it TYPE TABLE OF edidd WITH HEADER LINE.
    edidd-sdata = '315934 EA 017'.
    WRITE edidd-sdata.
    APPEND edidd TO it.
    edidd-sdata = '315934 EA 018'.
    APPEND edidd TO it.
    LOOP AT it." where segnam = 'E1EDP10'.
      CLEAR e1edp10.
      MOVE it-sdata TO e1edp10.
      DELETE it WHERE sdata = e1edp10-idnkd.
    ENDLOOP.
    in this also delete is working perfectly fine... you run and check..

  • BAPI not working in Java Webdynpro

    Hi,
    My BAPI from SAP is working in Netweaver perfectly, but when I call the same with the equal parameters in Java webdynpro, no results.
    I'm using following function: 'CVAPI_DOC_VIEW'.
    Any idea why the BAPI is not working in Java Webdynpro?
    Regards,
    Tim

    Hi Tim,
    AFAIK 'CVAPI_DOC_VIEW'  will work only in standard SAP Dynpro. Inside Webdynpro it is forbidden to save files in the background and using GUI class with execute, so you cannot use that Standard FM.
    Check this thread .
    Thanks
    Katrice

  • Paid subscription, but all products still in trial mode and does not work!

    Hello!
    I paid subscription, but all products still in trial mode and does not work! In Adobe ID manage page i don't see my subscription Screenshot “Adobe ID”
    I received an email confirmation of my payment subscription. Order number 12984126025, my adobe id
    [personal information removed... Mod - https://forums.adobe.com/docs/DOC-3731]
    [This is an open forum, not Adobe support, please do not post personal information]
    Why so?! This is very important! My current project at risk, I can lose money

    Please try the below mentioned steps
    1) Sign out of the Creative Cloud app
    2) delete the opm.db file*
    3) update to the latest version of the Creative Cloud app.
    *On Windows 7, the opm.db file is located here:
    C:\Users\YourUserName\AppData\Local\Adobe\OOBE
    *On a Mac, go here:
    [Userdir]:Library:Application Support:Adobe
    ~Deepak

  • Drag and Drop not working since last software update

    Drag and Drop not working since last software update - this is occuring on Outlook for the mac and I just tried moving  an icon on the doc and the same thing occured.  YOu can drag but the items will not drop.

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up a guest account” (without the quotes) in the search box.
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem(s)?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    Note: If you’ve activated “Find My Mac” or FileVault in Mac OS X 10.7 or later, then you can’t enable the Guest account. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. The instructions provided by Apple are as follows:
    Be sure your Mac is shut down.
    Press the power button.
    Immediately after you hear the startup tone, hold the Shift key. The Shift key should be held as soon as possible after the startup tone, but not before the tone.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem(s)?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • Delete command does not work

    delete command does not work.. it just freezes neither roll back happens.. please advice

    Always: If possible, give the exact command & output from your terminal, pefrerrable with copy & paste. We cannot see your screen and magically spot the problem.
    In general, you should also include your database version and OS, although I doubt that this is relevant in this particular case.
    Kind regards
    Uwe Hesse
    http://uhesse.wordpress.com

  • Brand new macbook --- DELETE KEY DOES NOT WORK --- how to fix?

    I have a brand new MacBook and the delete key does not work. Is there a way to fix this?

    You have 14 days to exchange it no questions asked.

Maybe you are looking for

  • Print driver problems with OS X version 10.4.6

    I recently installed TIGER 10.4.6 and have been unable to print on a Lexmark Optra T614 (duplex). All was working fine until the upgrade to TIGER!! I have downloaded a driver from Lexmark's website and (supposedly) successfully installed it to my sys

  • Strange query behavior when displayed in browser.

    Hi gurus, when I open a query in browser on one of the computers, I get no detailed cells, just the overall result. No matter, if I open the query in Portal, or in BEx Web Analyzer. When I use BEx Analyzer, everything seems to be fine. When I open th

  • Exchange 2013 Load Balancing Question

    Hey Everyone,     I have recently started building up my companies Exchange 2013 environment and ran into some questions that I can't seem to find clear answers for on Google.     First, a little bit about my set up: 2 CAS Servers 2 Mailbox Servers C

  • Distribution center as plant or storage location

    Hi Experts, If I have a distribution center at a particular location, how to decide whether it should be configured as plant or as a storage location?

  • A way to reduce margins when printing multiple pages per sheet?

    I really like the new leopard print dialog box. Is there a way of reducing the large margins when printing 2, 4, or more pages per sheet (in Layout)?