Help required on deleting temporary files through program

I could able to create, write and read from a temporary file. But I am unable to delete it. Can anyone help me to fix this. Here is the code.
Thanks in advance.
import java.io.*;
public class Test {
   File file1 = new File("C:\\temp");
   public static void main(String[] args)throws Exception {
       Test t = new Test();
        t.createTempFiles();
        t.read();
        t.delete();
    public void createTempFiles(){
        try{
            File temp = File .createTempFile( "TempFileName", ".tmp", new File ( "C:\\temp" ) );
            BufferedWriter bufferWriter = new BufferedWriter(new FileWriter(temp));
            bufferWriter.write("Temporary File");
            bufferWriter.close();
         catch(Exception exp){
            exp.printStackTrace();
   public void read()throws Exception{
       File file[] = file1.listFiles();
        for(File obj: file){
        BufferedReader reader = new BufferedReader(new FileReader(obj);
        System.out.println(reader.readLine());
   public void delete(){
      File file[] = file1.listFiles();
      for(File fl : file){
         System.out.println(fl.delete());
}

I think you are unable to delete because you never close the reader, so the operating system reports the file is still in use.

Similar Messages

  • How to delete temporary files on IPAD2?and is it possible or required!

    Dear all ,how to delete temporary files on iPad2

    Other than the browser items that King Penguin has described for you, there are no temporary files that are stored on the iPad. The iPad iOS does not work the same that a computer's OS works. There is nothing to delete.

  • How can I delete temporary files in FF. This is very simple in IE but feature cannot be found in FF

    IE has a simple means to delete both cookies and temporary files. I can delete cookies in FF but there is no way found to delete temporary files. This is a design feature flaw I assume since I cannot imagine this feature is not in the design..just can't be found. I have no idea about the educated guess of "installed plugins". My use of Firefox is just plain vanilla. I've never added any plugins to it.
    Any help appreciated.

    See:<br />
    - https://support.mozilla.com/en-US/kb/Clearing+private+data<br />
    - https://support.mozilla.com/en-US/kb/How+to+clear+the+cache
    Also see: https://support.mozilla.com/en-US/kb/Options+window+-+Privacy+panel<br />
    Tools > Options > Privacy > "Clear history when Firefox closes" > Settings
    <br />
    The information submitted with your question indicates that you have out of date plugins with known security issues that should be updated. To see the plugins submitted with your question, click "More system details..." to the right of your original question post.
    * Adobe Shockwave for Director Netscape plug-in, version 11.0
    * Adobe PDF Plug-In For Firefox and Netscape 8.2.5
    * Next Generation Java Plug-in 1.6.0_21 for Mozilla browsers
    #'''Check your plugin versions''': http://www.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #'''Update Shockwave for Director'''
    #*NOTE: this is not the same as Shockwave Flash; this installs the Shockwave Player.
    #*Use Firefox to download and SAVE the installer to your hard drive from the link in the article below (Desktop is a good place so you can find it).
    #*When the download is complete, exit Firefox (File > Exit)
    #*locate and double-click in the installer you just downloaded, let the install complete.
    #*Restart Firefox and check your plugins again.
    #*'''<u>Download link and more information</u>''': http://support.mozilla.com/en-US/kb/Using+the+Shockwave+plugin+with+Firefox
    #'''Update Adobe Reader (PDF plugin):'''
    #*From within your existing Adobe Reader ('''<u>if you have it already installed</u>'''):
    #**Open the Adobe Reader program from your Programs list
    #**Click Help > Check for Updates
    #**Follow the prompts for updating
    #**If this method works for you, skip the "Download complete installer" section below and proceed to "After the installation" below
    #*Download complete installer ('''if you do <u>NOT</u> have Adobe Reader installed'''):
    #**Use Firefox to download and SAVE the installer to your hard drive from the link in the article below
    #**On the Adobe page, un-check any extra items (i.e. Free McAfee® Security Scan Plus) then click Download button
    #**If you see message just under tabs, DO NOT click the Allow button, instead click below that where it says "click here to download".
    #**Click "Save to File"; save to your Desktop (so you can find it)
    #**After download completes, close Firefox
    #**Click the installer you just downloaded and allow the install to continue
    #***Note: Vista and Win7 users may need to right-click the installer and choose "Run as Administrator"
    #**'''<u>Download link and more information</u>''': https://support.mozilla.com/en-US/kb/Using+the+Adobe+Reader+plugin+with+Firefox#Installing_and_updating_Adobe_Reader
    #*After the installation, start Firefox and check your version again.
    #'''Update Java:'''
    #* Download and update instructions: https://support.mozilla.com/en-US/kb/Using+the+Java+plugin+with+Firefox
    #* Removing old versions (if needed): http://www.java.com/en/download/faq/remove_olderversions.xml
    #* Remove multiple Java Console extensions (if needed): http://kb.mozillazine.org/Java#Multiple_Java_Console_extensions
    #* After the installation, start Firefox and check your version again.

  • HT1923 When attempting a reinstall of iTunes, I cant delete the file C\Program Files\Common Files\Apple\Internet Services\Shellstream.resources due to same error message as described above for iPod file; however i can't find it anywhere in the Task Manage

    When attempting a reinstall of iTunes, I cant delete the file C\Program Files\Common Files\Apple\Internet Services\Shellstream.resources due to same error message as described above for iPod file; however i can't find it anywhere in the Task Manager

    That one's consistent with disk/file damage. The first thing I'd try with that is running a disk check (chkdsk) over your C drive.
    XP instructions in the following document: How to perform disk error checking in Windows XP
    Vista instructions in the following document: Check your hard disk for errors
    Windows 7 instructions in the following document: How to use CHKDSK (Check Disk)
    Select both Automatically fix file system errors and Scan for and attempt recovery of bad sectors, or use chkdsk /r (depending on which way you decide to go about doing this). You'll almost certainly have to schedule the chkdsk to run on startup. The scan should take quite a while ... if it quits after a few minutes or seconds, something's interfering with the scan.
    Does the chkdsk find/repair any damage? If so, can you get an install to go through properly afterwards?

  • Deleting  temporary files

    How do I delete temporary files?

    I wish I knew.
    I have downloaded some photos on to a USB stick.  The stick has also created temorary files, which I need to eliminate as they cannot be viewed on a BluRay player.   How can I eliminate these tempoary files from the stick?  Alternatively how can I avoid temporay files being downloaded in the first place?

  • Checking for and Deleting Temporary files etc.

    I use a PC at work and know how to delete temporary files. In fact it just asked me if it wanted to check and delete uncessesary files. How do I do this on my new imac?
    Thanks.
    Kevin

    Not at all necessary, the Mac takes care of that and most other maintenance chores on it's on it's own
    Just enjoy using it
    -mj

  • Very Urjent: How to delete temporary files on the server.

    EBS:
    We are facing a big issue with huge volume of temporary directory.We have created invoice program which uses Bursting concept. Every concurrent program is erroring out. How to delete those files automarically.
    Where these temp files are getting stored. How can we delete them once the concurrent request is completed.
    Please help me..its a huge issue. Thanks in advance.

    Sorry Steven,
    I saw your solution. Thanks for that. But I just want to know, do we have any setups in XML Publisher Administrator or bursting control file to delete the files automatically once the concurrent request is completed.
    And one more thing I found is, In the xml administrator, General properties i have specified the temporary directory as '/tmp'. But all the temporary files are loading in '$XDO_TOP/temp' directory. Why is this..

  • How to display attachment and delete temporary file  in Workflow

    Hello
    I have one question regarding function module SAP_WAPI_DIALOG_NOTES_DISPLAY.
    When a text file is selected, the target file is downloaded to Sapworkdir, and it's automatically deleted after displaying,
    This is pretty good behavior.
    But an Excel file is selected, the downloaded file is remained.
    I did not test other file types, but I need to delete such temporary files.
    If anyone would answer to the following questions, it's highly appreciated.
    1. This is a systematic difference or not?
    2. How to know exact downloaded temporary file's name.  ( I could search Sapworkdir and guess, but its' not good idea, I think.)
    Thank you and Best regards,
    Yuko

    Hi,
    you can try to use the:
    <b>ConsumerTreeListPreview</b>
    layout for KM navigation ivew (or customize to your own).
    This layout shows a folder tree on the left, a document list on the right. When you click on a document from the list it shows the contents of the file on the bottom of the iview.
    Hope this helps,
    Romano

  • Deleting Temporary Files - Privacy issue

    I have a privacy question regarding word. If I'm working on a personal word document at work and I save it to an external usb drive, is there still some evidence of it, like a temporary file saved on my work computer hard drive?
    If so, is there a way to delete it? Also, if the document is password protected, would it stay that way in the temp file version?
    Thanks everyone!

    Temp files are only saved by Word if it crashes. If you have Word's preferences configured to create timed backups of files then there will be a backup saved of any edited file. You can prevent that by simply disabling the automatic backup option in Word's preferences. Temp files will not be password protected as far as I'm aware unless you have protected your account with File Vault. I'm not sure but I don't think Word has any internal way of saving a file with password protection. You can check Word's help to find out if that's possible.

  • Missing permissions to delete temporary files in xml forms builder

    Hi,
    we have the following problem:
    A user with role content manager is using the xml forms builder. Every time, he is saving or generating a project, a error message comes up, telling him, that some files *.xml.xlb.___save_file could not be deleted. Those are temporary files which are created during editing (I guess?!).
    As recommended by SAP, the content manager only has read/write permission on the used KM-folder. If the user has the role (NOT group!) Administrator, everything works just fine. The same is true when the permissions are added manually. Is this the only way to solve the problem or am I missing some configuration?
    Help appreciated.
    Best regards,
    Hauke Siehlmann

    Dear Hauke,      
    Hope you found a solution in the meantime for this permission issue. Hence I just give a very general comment on this. Generally such content admins are supposed to be System Principals in CM by role assignment.
    By this concept and default delivery on this it is assured that users having access to administrative iViews by role assignment does also have relevant permissions. See http://help.sap.com/saphelp_nw70/helpdata/en/19/56f28fbd4e11d5993b00508b6b8b11/frameset.htm.
    Whenever having custom specific roles this System Principal concept should be part of the design.
    Best Regards, Peter

  • How to delete temporary file created by disk utility

    I recently ran the DISK UTILITY to erase free space. During the "CREATING TEMPORARY FILE" phase the process was interrupted. I had 250GB of free space now I have none. When ERASE FREE SPACE is run, what is the name of the temporary file and where is it located so I may manually delete it? The HARD DISK UTILITY shows I have zero free space

    Restart the computer and empty the Trash, or delete any file. Click here for more information.
    (46218)

  • Can anyone help me in sending a file through FTP

    i have written a program to transfer files or directories in zipformat through FTP.i have also installed filezella server to check whether it is working or not.i have connected to filezella server but i am not able to send file.can any one send the code for sending the file.
    i have also tried the jakarta api sendfile ().but in that i don't what is mode means.
    for your reference i am sending the code as far developed.
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipInputStream;
    import org.apache.commons.net.ftp.*;
    import org.apache.commons.net.tftp.*;
    class FTPTransfer
    static public void main(String[]p)
    FTPTransfer ob = new FTPTransfer();
    // ob.Create_Zip_File(new File("outfile.zip"),new File[]{new File("c:\\trialtwo")}, false);
    ob.ftpConnect();
    // connecting to FTP server
    public void ftpConnect()
    boolean error = false;
    FTPClient ftp = null;
    try
    int reply;
    //ftp.connect("ftp.comcast.com");
    ftp = new FTPClient();
    ftp.connect( "localhost",21);
    // ftp.login( username, password );
    System.out.print("reply from FTP Server :"+ftp.getReplyString());
    // After connection attempt, you should check the reply code to verify
    // success.
    reply = ftp.getReplyCode();
    if(!FTPReply.isPositiveCompletion(reply)) {
    ftp.disconnect();
    System.err.println("FTP server refused connection.");
    System.exit(1);
    // ftp.sendFile();
    // transfer files
    // ftp.logout();
    TFTPClient tftp = new TFTPClient();
    System.out.print("before sending");
    tftp.sendFile("c:\\trialtwo\\a-1.txt",1,new FileInputStream("c:\\trialtwo\\a-1.txt"),"localhost",21);
    System.out.print("after sending");
    catch(IOException e)
    error = true;
    e.printStackTrace();
    finally
    if(ftp.isConnected())
    try
    ftp.disconnect();
    catch(IOException ioe)
    // do nothing
    System.exit(error ? 1 : 0);
    //send files
    // filename - The name the remote server should use when creating the file on its file system.
    // mode - The TFTP mode of the transfer (one of the MODE constants).
    // host - The remote host receiving the file.
    //port - The port number of the remote TFTP server.
    private void listContents( File Zip_File, File dir, ZipOutputStream out )
    throws Exception
    String[] files;
    files = dir.list();
    byte[] buf = new byte[1024];
    File[] file = dir.listFiles();
    for (int i = 0; i < file.length; i++) {
    System.out.println("*********** "+file);
    // File f = new File(dir,file[i]);
    try{
    FileInputStream in = new FileInputStream(file[i]);
    out.putNextEntry(new ZipEntry(file[i].getPath()));
    int len;
    while((len = in.read(buf)) > 0) {
    out.write(buf, 0, len);
    in.close();
    catch(Exception e)
    zipEntry(Zip_File, file[i], out);
    } // end listContents()
    void Create_Zip_File(File Zip_File,File[] To_Be_Zipped_Files,boolean Skip_Dirs)
    try
    // Open archive file
    FileOutputStream stream=new FileOutputStream(Zip_File);
    ZipOutputStream out=new ZipOutputStream(stream);
    for (int i=0;i<To_Be_Zipped_Files.length;i++)
    //if (To_Be_Zipped_Files[i]==null
    // || !To_Be_Zipped_Files[i].exists()
    // || (Skip_Dirs ))
    // continue;
    System.out.println("Adding "+To_Be_Zipped_Files[i].getName());
    zipEntry(Zip_File, To_Be_Zipped_Files[i], out);
    out.close();
    stream.close();
    System.out.println("Finished zipping : "+ Zip_File.getAbsolutePath());
    catch (Exception e)
    e.printStackTrace();
    System.out.println("Error: " + e.getMessage());
    return;
    private void zipEntry(File Zip_File, File file, ZipOutputStream out) throws Exception
    if (file.isDirectory())
    listContents(Zip_File, file, out);
    return;

    You'll stand a better chance of getting help if you're more specific about what problems you're encountering. "Can't send file" doesn't say much.
    When you post code, please use[code] and [/code] tags as described in Formatting tips on the message entry page. It makes it much easier to read.

  • HELP. I deleted some files, but they are still in the Nib I think

    I have royally messed up. I'm working on a cocoa app with various Quartz Compositions in it using QC View's. The .qtz files have been loaded into the Nib via the QC View's, but by accident I have deleted the original .qtz files from my disk.
    I can still build the application and the views work as it seems the .qtz files must be cached into the nib file. However I can't get to them to save them back to my disk. Is there any way to get a .qtz file out of a nib after its been loaded in. Perhaps some way to reverse save the file out to disk?
    Sorry its so rambling, its just that I've spent weeks getting these compositions right and now I've gone and deleted them I'm beside myself
    I have tried looking inside the the nib file with 'Show package contents' but none of the .qtz files are in there. How are they cached in the nib?
    Thanks you for any help. I'm also trying various file recovery apps, but so far no luck.
    Mark

    I tried all sorts of utilities to get the files back, but no luck. So I sat down with plenty of coffee and retraced my work as best I could remember.
    After a full days work, I have recreated all the files and actually made quite a few improvements along the way!! Although I lost some time, I actually ended with a better end product, so not such a disaster after all

  • Help required in embedding flash file object into Crystal Report file.

    Hello,
          I use the default version of Crystal Report (i.e.'Crystal Report Basic For Visual Studio 2008 - version 10.5' ) which is the part of 'Visual Studio 2008', to create and display the Report. Further, as a requirement, I have to show 'Event Video' into the Report. But, as this default version of Crystal Report does not support Flash File, I uninstalled it and downloaded and installed the 30 days trial version of the Crystal Report (i.e. Crystal Report 2008 - version 12.0).
          Then, I created a new Crystal Report File using 'Crystal Report 2008 Designer', embedded the video as a Flash File(i.e. SWF file) into it. Now,  when I add this newly created Crystal Report File into my sample application, which is created using VS 2008, it does not shows the embedded video.
          So, can anybody please tell me, how can I embed the Flash File into Crystal Report, so that it will be visible in the sample application?
    I would like to appreciate your help and support.
    Thanks,
    -Yogesh.

    Symptom :
    When embedding a pdf document into a Crystal Report, only the one page shows.
    Reproducing the Issue
    Environment:
    Crystal Reports OLE object
    Cause
    An OLE object only displays the first page.
    Resolution
    Embed multiple objects, one for each page
    Or
    Use a hyperlink to the object instead
    Hope this helps!
    Regards,
    Vinay

  • Help required on Execution of Surveys through E-mail Campaigns

    Dear all,
    Our Client wants to execute the Customer Satisfaction Survey through an E-mail Campaign and wants to receive the customer feedback to evaluate the customer response.
    I have the following concerns to map this requirement in SAP CRM
    1. as per some SAP documentation we have to create an URL link for our Survey, here how can we insert this link in to an E-mail? Should we need to create a personalized E-mail form to insert this link?
    2. Upon customer clicks on this URL link, and enters the feedback form, how the responses are getting back to CRM server and  where the Questions and answers are storing in SAP?
    3. What configuration do we need to do in SAP CRM to achieve this requirement?
    4. How can we evaluate the Customer answers and responses without integrating BIW system?
    5. What standard reports available in SAP CRM to evaluate the customer response based on ratings given to the each answer?
    6. How to track whether customer review the mail or not, in case if customer doesn't want to give the feedback?
    I believe that, in SAP CRM a standard solution and reports will be available to address this requirement. I request you to help me in resolving the problem.
    it would be helpful if you can refere andy step by step configuration manual for this requirement.
    Your suggestions and help will be highly appreciated.
    Thank you
    Raghu ram

    There are quite a few threads with these questions answered in this forum:
    SAP CRM: Marketing

Maybe you are looking for