File in the Uppen mode is not getting deleted !

Hello All,
I am creating a file, writing data into it, later, send this file as an email attachment and then delete the file. --This entire thing is in while loop.
My problem:
I could create a file(in append mode,) write data into it and send it as an attachment. But,
I am not able to delete the file...
Here is the code.
code to create a file
<%!private void rowhdr()
                                                  try
                                                            System.out.println("Writing to file-rowhrd");
                                                  FileWriter fos = new FileWriter("C:/Ash/detail.txt",true);
                                                  BufferedWriter bw = new BufferedWriter(fos);
                                                  PrintWriter pw = new PrintWriter(fos, true);
                                                  pw.println("Gform No      Sales Prom.    Local Travel     Subspn         Entertainment    Telephone  Conf/Seminar  Mobile/Res_Tel    others   Advance    Ticketamt      Net    Remarks");
                                                  System.out.println("Finished writing-rowhrd");
                                                  } catch (IOException ioe) {
                                                            System.out.println( "Append IO error:" + ioe );
          %>code to delete the file
<%!private void createfile(boolean del)
                                                            try {
                                                                 File temp= null;                         
                                                                  temp= new File("C:/Ash/detail.txt");
                                                                      boolean ch=temp.createNewFile();
                                                                      if(ch)
                                                                           System.out.println("file created");
                                                                      else
                                                                           System.out.println("file Not created");
                                                                           System.out.println("del value in delete block="+del);
                                                                           if(del)
                                                                                               boolean er=temp.delete();
                                                                                               System.out.println("Erase="+er);
                                                                                               if(er)
                                                                                               System.out.println("file deleted");
                                                                      }//end of else pare of if-ch
                                                       } catch (IOException ioe)
                                                                           System.out.println( "Append IO error:" + ioe );
%>I am getting value of del=true, but er=false.
I don't know why?
can anyone help me please?
Regards, Thanks in advance.
Ashvini

I dont follow your post, but here's a simple program to open a file in "rw" mode, write to it and delete after 10 seconds. It works.
package com.my;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class FileWrite
    public static void main(String args[])
        try
            FileWriter fos = new FileWriter("path", true);           
            PrintWriter pw = new PrintWriter(fos, true);
            pw.println("Gform No      Sales Prom.    Local Travel     Subspn         Entertainment    Telephone  Conf/Seminar  Mobile/Res_Tel    others   Advance    Ticketamt      Net    Remarks");
            Thread.sleep(10000);
            pw.close();           
            fos.close();
            File f = new File("same path as given above");
            f.delete();
        catch (Exception ioe)
            System.out.println("Append IO error:" + ioe);
    }cheers,
ram.

Similar Messages

  • File not getting deleted using File.delete()

    Hi guys,
    I have a code like this:
    File tempdir = new File("tempdir");
    tempdir.mkdir();
    File temporaryFile = new File("tempdir\tempfile.txt");
    FileWriter writer = new FileWriter(temporaryFile);
    // write data into file
    writer.flush();
    writer.close();
    try {
        // Do something
    catch (Exception e) {
        // Do something
    temporaryFile.delete();
    tempdir.delete();The program runs successfully. The directory and the file is created and data is written successfully into it. However, the file as well as directory is not getting deleted at the end of the program. I tried temporaryFile.deleteOnExit(), but this also didn't help.
    Can anyone provide some input as to what can be the possible reasons for the file not getting deleted?
    Thanks..

    I want the file to be created inside the directory I specified. Hence, I put the "\". Please let me know if there is some other way to achieve this. This way I am getting the file created at the location I want.
    One more interesting thing which I noticed. Actually this code is part of a JUnit test. In the same JUnit, I am creating new files in atleast 2-3 test methods. But the deletion of files is really random. Sometimes, 2 out of 3 get deleted, sometimes only 1 gets deleted. However, I didn't come through a single instance wherein all the 3 files got deleted. :-(
    Also, the directory is never deleted. However, I got the reason behind this. As per the File API, the directory will not be deleted if it is not empty.

  • Message log is not getting deleted in WEBUI (BADI ORDER_SAVE)

    Hi,
    I am displaying an error message based on certain conditions in BADI: ORDER_SAVE (CHECK_BEFORE_SAVE). On getting error, I am correcting that error.
    Using CRM_MESSAGE_DELETE, I am deleting error message before displaying new error message. However, my error log is not going away. It is still displaying in the log in WEBUI.
    Could you please help me out, how can I delete error message, and error log from WEBUI.
    Thanks,
    Sandeep

    I  have the same question as you .
       I  have use folleing code to display message in web ui:
          if (conditions).
          CV_OWN_MESSAGE = 'X'.
          MESSAGE '商机描述已经存在,请修改后再保存!' type 'E' RAISING DO_NOT_SAVE .
        endif.
    but when i have edit the description , the Message log is not getting deleted in WEBUI .
    who can tell me , thanks for all your help !

  • Open TRs not getting deleted after TECO production order

    Hi,
    We're having an issue.  We're using WMPP interface to supply the production line for the production orders.  The auto TRs are generated when the production orders are released. 
    After TECO the production orders, the open TRs are not getting deleted automatically.
    Could anyone know if these TRs get deleted automatically when we do the TECO production order?
    If yes, do we have any restriction or condition based on this, the TRs get deleted?
    Please explain.
    Thank you.
    with regards,
    Muthu.

    Hi Abhijit,
    Thank you for your reply.  It does not help me.
    The auto TR creation is happening now as required.  No issue on this.
    When you do the TECO, it also cancels the TRs.  I tested this also. 
    There're some scenario this open TRs cancellation is not happening.  I do not know when these open TRs are not cancelled.  If you know answer for this, please let me know.
    Thank you for your help and time.
    with regards,
    Muthu.

  • Spool Requests in Waiting not getting deleted by RSPO0041 or RSPO1041

    Hello Experts,
    We are currently running report RSPO0041 in our system to delete old spool requests, this report is running fine and deleting other spool requests except in status "waiting".
    I have also done test run with RSPO1041, but even though the requests in the status waiting are not getting deleted. The only option I have is to delete it by SPAD.
    The issue I have is that, the output device is not defined for a set of users, due to which their requests are picking up Frontend printing which is not possible which is the cause large number of requests are going in status waiting.
    We are not in a position to define output device for such users. 
    My question here is: Do we have any other option in above reports to include the spool with status waiting?
    Your valuable advice needed. Thanks in advance.
    Regards,
    Amit

    Hi Amit,
    What is the option you are selecting in both of these reports? Make sure you have selected "in processing" and "without output request" in rspo1041 with the corresponding dates, then I am sure it will get deleted.

  • REM tick not getting deleted for Part no

    Dear All ,
    we have one material which had Procurement type " E " ( In-house SFG ) , But now the Part is totally Procured from vendor .
    So the Procurement type is changed to " F " .   So we need to do the Material Master Correction .
    If we Try to delete REM tick from Material Master , Following Message is seen >>>>>>
    Production versions exist for which repetitive manufacturing is allowed
    Message no. M3636
    If Try to delete the REM tick from Production Version , Following Message is seen >>>>>
    Production version 1 or repetitive mfg indicator cannot be deleted
    Message no. KOSA012
    Even the Production Version is not getting deleted .  Following Message is seen >>>>>
    Production version 1 or repetitive mfg indicator cannot be deleted
    How to handle the above issue ?   Please guide . Thanx in advance

    Dear Vasu,
    check after performing these activities,
    Deleting the Production Version
    Use
    The production version contains the technical information on how a material can be manufactured. If this technical method has become outdated, you can delete the production version.
    Prerequisites
    1.You must settle the product cost collector you created for the production version.
    2.No more planned orders exist in the system which are assigned to this production version.
    3.If you work with reporting points in make-to-stock REM, no more work in process (WIP) exists on the production line in question. That is, work in process must be closed in the period-end closing in Cost Object Controlling.
    4.If an inspection lot exists, you must already have made the usage decision for the inspection lot.
    5.For the period in which the last reporting point backflush was carried out and for all previous periods in which the run schedule header or the production version is valid.
    6.the cutoff period is set for the WIP calculation
    7.the cutoff period is set for the variance calculation (operation KVAR)
    Regards
    Mangalraj.S

  • Email delete on computer (Exchange) not getting deleted on iPhone 5s

    Using a Macbook Pro w/ Retina Display and OSX 10.9 (Mavericks), when I delete or move an email on the computer it's not getting deleted or moved on the iPhone 5s (IOS 7). I upgraded to iPhone 5s yesterday from iPhone 4 (IOS 6). (The mail was working properly on the old phone.) I looked for, but didn't find anything in "Settings" to fix the problem.
    Any help is appreciated.

    Yeah, my boss has a similar problem.
    When he deletes email on his iPhone it re-appears after a couple of seconds. That is the iPhone is not really deleting email from the Exchange Server.
    Here's the rub. We just got him a new iMAC and he's running Fusion so that he can get to his Outlook "Notes", which Entourage doesn't support.
    So...he has Entourage open on the iMAC and Outlook open in Fusion.
    If Entourage is closed down and he deletes email from the iPhone, it IS deleted from Outlook/Exchange and doesn't reappear.
    However, if Entourage is OPEN, regardless of whether Outlook is open or not, the mail is NOT deleted from Entourage, causing it to reappear on the iPhone.
    Obviously the solution is not to use Entourage so I guess that's what we'll have to do until we can do a complete conversion to Apple and use Apple Mail on OSX. Alternatively I'm exploring using Google mail instead of Exchange.
    I'm afraid there isn't a good solution to this problem?

  • File is not getting deleted in File-RFC-File without BPM

    Hi,
    I'm working on File-RFC-File scenario without BPM. Everything is working fine except file is not getting deleted after the process. I'm passing xml file here and in return it will give the xml success/error message from RFC.
    For the sender CC, I'm passing the following parameters,
    Transsport protocol: File system
    Message protocol: File
    QoS: BE
    Poll Interval: 30 sec
    Mode: Delete
    File type: Binay
    Please let me know if I missed anything while passing the values.
    Thanks,
    Swamy
    Edited by: Swamy Mothe on Jun 15, 2009 8:52 AM

    Hi
    Then , is Sender and receiver File Adapter is using same folder )
    Just a question.
    But having all permisions and above config would delete the file
    can u see the status of u r File Adapter in RWB.? Is it in green?
    rgds
    srini

  • An error occured while creating the new dataset Could not get type informat

    Uses: Windows XP Pro SP3+; OracleXE; Oracle 8i Client; ODP.NET; Visual Studio 2005 PRO;
    I had OracleXE and was using OracleXE's Oracle.DataAccess Version 10.2.0.100 which was located in C:\oraclexe\app\oracle\product\10.2.0\server\BIN. Then to use Oracle Developer Tools for VS, I installed ODAC where the Oracle.DataAccess's version was 2.111.6.20.
    Everything connected via SqlPlus and even was able to Oracle XE Home page and was able to loginto it. Further, was even able to create connection with Oracle Dot Net Provider. The problem was created when I tried to create a datasource from DataSource Menu in VS.2005. It was giving an error saying "An error occured while creating the new dataset Could not get type information for dataset". However I wittnessed that Dataset is been created in Solutions Explorer but not in Data Source Tab. Further researching I was able to create Datasets with Microsofts Oracle Data provider with out any issue.
    My Path variable list the following:
    C:\app\Administrator\product\11.1.0\client_1;
    C:\app\Administrator\product\11.1.0\client_1\bin;
    C:\oraclexe\app\oracle\product\10.2.0\server\bin;
    C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\;
    C:\Program Files\Borland\BDS\4.0\Bin;
    C:\PROGRA~1\Borland\Delphi5\Projects\Bpl;
    C:\PROGRA~1\Borland\vbroker\jre\Bin;
    C:\PROGRA~1\Borland\vbroker\Bin;
    C:\PROGRA~1\Borland\Delphi5\Bin;C:\orant\bin;
    C:\WINDOWS\system32;C:\WINDOWS;
    C:\WINDOWS\System32\Wbem;
    c:\Program Files\Microsoft SQL Server\90\Tools\binn\;
    C:\Program Files\Microsoft SQL Server\80\Tools\BINN;
    C:\Program Files\java\jdk1.6.0_07\bin.
    Further I got 2 Oracle Homes one which C:\orant and other is located in C:\app\Administrator\product\11.1.0\client_1.
    Also noted that while deploying at client site I started gett'n this error:
    "Unable to install or run the application. The application requires that assembly Oracle.DataAcces version be installed in Global Assembly Cache First."
    Is it due to change in the production machine? Any help in this regard is greatly appreciated.

    Hi Pushpa,
    Which enhancement package are you on currently? This is observed in cases where originals in DIR's are invisible and sometimes error message 26296 occurs in transaction CV01n. Hence,please check your entries in the table SDOKPROP to avoid such a problem in your system.
    Further,suggest you explore if the below resolutions can be adopted in your case.
    http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=10321987
    http://wiki.sdn.sap.com/wiki/display/PLM/OriginalsinvisibleafterEHP3or+EHP4
    Regards,
    Pradeepkumar haragoldavar

  • I can no longer get to Facebook Via firefox It comes up loading in the tab but does not get any further one minute it was working the next it was,nt should I try uninstalling firefox then reinstall or does anyone know what could of happened thanks

    # Question
    I can no longer get to Facebook Via firefox It comes up loading in the tab but does not get any further one minute it was working the next it was,nt should I try uninstalling firefox then reinstall or does anyone know what could of happened thanks

    * "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    * "Remove the Cookies" from sites that cause problems: Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]

  • Release  PR Should not get deleted in md51,planning mode 3

    Hi all,
    We are facing a problem in MRP run taken through transaction code MD51. This Problem (as explained below) will occur when MRP control parameter for Planning Mode will be set to u20183u2019 (Delete and recreate planning data).
    During normal course, if MRP control parameter for Planning mode is set to u20183u2019, system deletes all open PR & Planned orders & creates new PR & new planned orders. 
    But in our business scenario, where we have release strategy for MRP generated PR, even these released PR get deleted. This results in re-analysis & releasing of MRP generated PR which itself is a tedious & time consuming task.
    We are looking for a solution where  PR will not get deleted during MRP.
    Thanks
    Sukumar
    Edited by: skumar kalame on Nov 10, 2008 1:59 PM

    Hi,
    The planing time fence is maintained in MRP-1 view of the material in workdays. You can also have this defined in the MRP group. But the value in material master takes precedence over MRP group.
    Use - It is a kind of safety fence which is used to protect any automatic changes to take place for firm order proposals during MRP run.
    Depends on - Firming indicator needs to be maintained for the MRP type. This can be set in customizing for the MRP Type. This basically specifies how you want to firm the order proposals. Please note there are 5 types of firming
    The SAP help for firming type reads as below:
    firming type 0
    The system does not firm procurement proposals automatically.
    firming type 1
    Procurement proposals that move into the planning time fence are firmed automatically, as soon as their date lies at least one day before the end date of the planning time fence. The date of new procurement proposals that are created in the planning time fence is displaced to the end of the planning time fence. These new procurement proposals are not firmed.
    firming type 2
    Procurement proposals that move into the planning time fence are firmed automatically, as soon as their date lies at least one day before the end date of the planning time fence. The system does not create any new procurement proposals within the planning time fence; that means, the system does not balance the shortage situation in the planning time fence.
    firming type 3
    Procurement proposals that move into the planning time fence are not firmed automatically by the system. All procurement proposals that are necessary for requirements coverage are displaced to the end of the planning time fence.
    firming type 4
    Procurement proposals that move into the planning time fence are not firmed automatically by the system. The system does not create any new procurement proposals within the planning time fence; that means, the system does not balance the shortage situation in the planning time fence.
    If helpful award points
    Regards,
    Vivek

  • "could not read the file because the plug-in could not understand the file."

    "could not read the file because the plug-in could not understand the file."
    I keep getting this error when trying to open some of my illustrator files. Usually after trying 5 or 6 time it will mysteriously open without a problem. I've reinstalled Illustrator and that didn't work. I've uninstalled and reinstalled CS3 and that didn't work.
    Why does it sometimes open and sometimes not???
    I've lost I don't know how many hours screwing around with this and REALLY pissing me off!!!
    AURGH!

    I think this has something to do with the PNG plugin.

  • Temporary files are not getting deleted

    Hi All,
    I am using informix database and my code is reading BLOB from database and writing the image to different storage media. The program has to run for number of images. It is writing to media successfully but not exiting even after printing the last statement in program. it is generating some temporary files ifxb_* . If I use System.exit() garbage collection is not happeneing and temporary files not getting deleted.
    I am storing BLOB to an InputStream. and closing all the Connections and ResultSet before exit.
    Can anyone please tell why program is not exiting normally?

    gtRpr wrote:
    It doesn't make much sense to me to go through extra work to make code insecure, when doing things the right way is easier and more secure.@yawmark - I get it, relax.
    I never used them last year because I only found out about there existance about 4 Months ago.
    And guess what I have never used normal statements for something like that again.
    Only time I use a normal Statement is when I run that query only once, and no the entire query is hardcoded so no need for any worries due to security.Um ... D'you post this to the wrong forum/topic?
    Anyway, OP ... I don't know a thing about informix, so perhaps a trip over to IBM would help ... they have lots of information on their site. You might want to try a different forum right here at java.sun.com as well.
    About those closing of Connections and Resultsets ... are they in finally clauses? They should be.
    ~Bill

  • Please help with "Error writing the project file. The specified module could not be found." error.

    I am a student.  I've been trying to install and use Visual Studio 2013 Professional for three weeks now and I cannot get it to work.  I am now two weeks behind in my Visual Basic class.  I've installed, uninstalled, ran the repair option... 
    I've tried everything I know how to do.  I just spent 45 minutes on the phone with Microsoft, was transferred four times and finally told I will have to use the forums to find an answer.  I'm almost completely out of patience with this.
    I got the software through the Dream Spark program as a student.  I installed it with the web installer and it appeared to install fine.  When I try to create a new project, I get the error:  "Error writing the project file.  The
    specified module could not be found."
    When I exit the application, I also get:  "The automatically saved settings file 'c:\users\user\documents\visual studio 2013\Settings\CurrentSettings-2015-02-02.vssettings' is not available for write.  You can change this file on the 'Import
    and Export Settings' Tools Options page."
    Please tell me you can help.

    Hi,
    could you please try the points mentioned here:
    http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/0376db8f-4761-4ae5-9af2-98c53216318a#VS_IDE_unexpected_problems to eliminate the possible cause of your issue?
    Please update the result in the forum after you try the method above!
    Best Wishes!
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • Suddenly I have problems moving files to the trash...  get a dialog saying Finder wants to make changes and I must provide the password... Any explanation or ideas how I can get this to stop?

    Suddenly I have problems moving files to the trash...  get a dialog saying Finder wants to make changes and I must provide the password... Any explanation or ideas how I can get this to stop?

    Please take these steps if you're prompted for a password when moving items in your home folder to the Trash.
    1. Triple-click anywhere in the line below on this page to select it:
    ~/.Trash
    2. Right-click or control-click the highlighted line and select
    Services ▹ Show Info
    from the contextual menu.* An Info dialog should open.
    3. The dialog should show "You can read and write" in the Sharing & Permissions section. If that's not what it shows, click the padlock icon in the lower right corner of the window and enter your password when prompted. Use the plus- and minus-sign buttons to give yourself Read & Write access and "everyone" No Access. Delete any other entries in the access list.
    4. In the General section, uncheck the box marked Locked if it's checked.
    5. From the action menu (gear icon) at the bottom of the dialog, select Apply to enclosed items and confirm.
    6. Close the Info window and test.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination command-C. Open a TextEdit window and paste into it (command-V). Select the line you just pasted and continue as above.

Maybe you are looking for

  • Ipad 2 can't see logitech bluetooth mouse M557

    Hi, I made sure that this mouse would connect to my ipad 2 before I bought it and other bluetooth equipment. My iPad sees and connects to everything else but not the mouse. I am able to connect the mouse fine to my HP laptop. I've checked the Apple w

  • What is a (Logic Express) aggregate device?

    Im not a complete newbie to the world of music tech, I'm just getting back into it after a few years away. There's one term which keeps cropping up on here which is completely alien to me: Aggregate Device What is an aggregate device? It seems to ref

  • HT4623 Greyed out sync to phone button

    Hi I have an iphone 4, which used to be synced with my Mothers itunes, but with my own username and password etc, I have now got itunes of my own and made a purchase tonight on itunes, however this tune will not go on to my phone for some reason...I

  • Elements 12 Installation/Run Problem

    The problem started when my Elements 10 would not open having been running sucessfully for months on my Windows 8 PC. It returned an error message which I think said there were files missing and I should reinstall. I tried reinstalling many times wit

  • Customer master XD01

    HI Gurus while creating xd01 i am getting below error like "Cust.grp 1 & 2 are Mandatory Fields" please explain me will reward you