File.delete() not working properly

Hi Forum!!
I am trying with the below code :
File file = new file("path");
try{
if(file.exists())
System.+gc+();
file.delete();
System.+out+.println("Control in delete trx file after deletion"+ file.exists());
}catch(SecurityException se){
String msg= "Delete trx file if 3gttz file created : IO Problems";
Log.+error+(msg, se);
}file.exists() returns false But I when I check file, it still exhists with content 0 bytes .
Is there a way to remove the entire file from the directory rather than deleting only the
contents ? Need not to tell I did my initial search to solve the problem.
Thanks
Edited by: jagabandhu on Feb 10, 2009 1:09 PM

georgemc wrote:
PhHein wrote:
corlettk wrote:
We can't all be rocket surgeons, either ;-)Heart scientist is the word you're looking for.Or rockin' sturgeons. A (marginally) cooler - albeit fictional - alternative to this abominationFrom a crazy drunk:
A "bottle in front of me" is better than a "frontal lobotomy"!
(Sound out those two quoted strings.)

Similar Messages

  • .jar file is not working properly :developed in NETBEANS

    Hi Gurus,
    i am using NETBEANS IDE 7.2.
    i am developing a project that interacts with databases 10g and COM ports of machine , these all processes are performed by .bat file which i am trying to run from jFramform , code works perfectly .bat file is also called perfectly when i run the project using F6 from the NETBEANS, for testing i placed some dialogue boxes on the form to test it ,
    but when i run executable .jar  file , form run successfully and dialogue box works perfectly but .bat file is not called by executable .jar file.
    this is how i call the .bat file...
      String filePath = "D:/pms/Libraries/portlib.bat";  
            try { 
              Process p = Runtime.getRuntime().exec(filePath); 
            } catch (Exception e) { 
                e.printStackTrace(); 
    and below is the contents of portlib.bat file
    java -jar "D:\SMS\SMS\dist\SMS.jar" 
    you must probably ask why i am calling a .jar file using .bat file .
    reason is that this .jar project sends message using GSM mobile , System.exit(); is compulsory to complete a job and then do the next one ,
    if i use the same file to execute this job it makes exit to entire the application (hope you can understand my logic).
    that's why i use extra .jar file in .bat file , when single job is completed .bat exits itself and new command is given.
    Problem is that code is working perfectly in NETBEANS when i run the project but when i run .jar then .bat file is not working  ,
    thanks.

    Thanks Sir ,
    You need to first test an example that works like the one in the article.
    There are plenty of other examples on the web - find one you like:
    http://javapapers.com/core-java/os-processes-using-java-processbuilder/
    I tried this one.
      try {
                ProcessBuilder dirProcess = new ProcessBuilder("D:/SMS/SMS/Send_message.bat");
                 File commands = new File("D:/SMS/SMS/Send_message.bat");
                 File dirOut = new File("C:/process/out.txt");
                 File dirErr = new File("C:/process/err.txt");
               dirProcess.redirectInput(commands);
                 dirProcess.redirectOutput(dirOut);
               dirProcess.redirectError(dirErr);
                 dirProcess.start();
            } catch (IOException ex) {
                Logger.getLogger(mainform.class.getName()).log(Level.SEVERE, null, ex);
    as instructed in the article i compiled  both the projects at same version or sources and libraries which is 1.7
    here is my version details
    C:\>javac -version
    javac 1.7.0_07
    C:\>java -version
    java version "1.7.0_07"
    Java(TM) SE Runtime Environment (build 1.7.0_07-b11)
    Java HotSpot(TM) Client VM (build 23.3-b01, mixed mode, sharing)
    inside the NETBEANS IDE c:\process\err.txt  remains empty and code works perfectly , but when I run executable .jar file( by double clicking on that file in dist directry) then c:\process\err.txt becomes full with this error text and there is no response from calling D:\SMS\SMS\send_message.bat
    here is the error text
    java.lang.UnsupportedClassVersionError: sms/SMSMAIN (Unsupported major.minor version 51.0)
      at java.lang.ClassLoader.defineClass0(Native Method)
      at java.lang.ClassLoader.defineClass(Unknown Source)
      at java.security.SecureClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.access$100(Unknown Source)
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Exception in thread "main"
    here is /SMS/SMS
    unknown source ?

  • File Monitor - Not working properly on SMB file share

    The "File Monitor" does not trigger on SMB file share, i think this might be a bug.
    I have tried the same "File Monitor" on a windows share, and it works like intended. However, when I use the same runbook on a Solaris SMB share, it does not trigger properly. It triggers when I delete or rename a file, but not any thing else (like
    create, changed, etc) I have turned all the triggers on just to see what actually makes it trigger...
    I'm using specified authentication (domain user and password)
    The SMB folder is shared on a Solaris (SunOS 5.10).
    Can anyone confirm that they also have this problem?
    Is there a patch to fix this? Thanks.

    Can someone please verify that they also have this problem?
    Thanks.

  • File.lastModified() not working properly.

    Hi,
    I need to check if the file is modified or not.So Iam using the following code.
    public void testLastModified() {
              for(int i =1 ;i < 10 ;i++){
              String filePath = "C:" + File.separator + "test1.rtf";
              File test1 = new File(filePath);
              if (test1.exists()) {
                   System.out.println("File exits");
                   if (test1.canRead()) {
                        System.out.println("Can read file");
                        if (test1.canWrite()) {
                             System.out.println("can write file");
                             long time = test1.lastModified();
                             System.out.println("last modified:" + time);
                             try {
                                  this.sleep(1000);
                             } catch (InterruptedException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                             System.out.println("wait completed");
                             System.out.println("last modified:" + test1.lastModified());
    while the thread is in sleep state for 1000 ms iam openning and modifying the file.But not saving it.
    The code prints the same modified time as that of the intial modified time.
    So can't we determine last modified time without saving the file.
    Thanks in advance.

    The question doesn't make any sense at all. If you haven't saved the modifications yet, the file hasn't been modified yet, so how could the last-modified date & time change? Why should it change?
    Having said that, some platforms don't modify this attribute until the file is closed.

  • File Sync not working properly

    Hopefully someone else has come across this problem. I'll try to set the stage here: I'm running D.W. CS6 and manage about a dozen Web Sites that have been up & running for years without ever seeing this problem.
    When I update a file i.e. contactus.html on my local server then try to sync it with remote server I get But the local file has changed...If I hit YES on the 'No Sync necessary' I get No files listed in the next screen,
    I can connect & see the remote files but can not Sync to it nor manually update it. I tried recreating the Site Cache but that did not help. I also deleted the dwsync.xml on local & restarted D,W. Same results.
    I guess I could delete the Site Definition & start over but I am not sure that would remedy my situation.
    Please assist, Thanks in advance. Pat 

    Synchronization in DW has always seemed to have random issues for me.
    To be honest, I just stopped using it all together and went with...
    Right click the root folder in the Files window
    Choose Select > Recently Modified
    Set the Days field to 1
    That will highlight anything changed in the last day according to DW itself (no server interaction required)
    Put the highlighted files
    You'll end up uploading a couple extra files, to be sure, but it's a lot faster than trying to find them by hand.

  • File Dependency not working properly

    Hi,
    In our project we have a job group which will move a set of file from one directory to another directory. The first job in that group will be run only when a file with an extension "ind" is present in the source directory, i.e the dependency is set to a file with extension *.ind(Please see attached screeshot for reference).
    But when we run the job the dependency is not being satisfied even though the file is present in the source directory.
    What could be the reason for this?
    Note: If I overide the job, then the files are properly griing moved. But since this is automated, the job run must be based on the dependency we have set.

    This sounds like the runtime user of the job is a different account than used by the agent.
    File Dependencies and File Events are evaluated by the agent process.  This means the account running the agent service must have access to the file.
    When the job runs it uses the runtime user.  If the runtime user is different account than the agent account you can encounter the problem you describe.
    If this is a Windows agent running as a Local System account, the agent will only have access to files local to the server.  So if the file is on another server the agent will not have access to it.
    If this isn't your issue, could you provide details about the agent (windows/unix), file location (local to agent/UNC path), and whether the agent running the job is the same as the agent being used to evaluate the file dependency.
    Thanks.

  • My JAR file is not working properly!!!

    Hi everyone,
    I made an application that has a GUI (window). I converted it into a JAR file so I can send it to a friend by email. Then she can run it to generate the output. First, the user has to select a destination to save the .txt file (using JFileChooser). Then enters the inputs (using JTextFields). Clicks "Run" button (Results will be calculated and copied to the file). A Message will appear indicating that the results are copied. The problem is that when I run the application in the IDE (Eclipse) it works fine. But when I convert it into JAR, The moment I click the "Run" button, suddenly the window closes. Please HELP???
    Thank you

    DrClap wrote:
    Eng.Sh_2004 wrote:
    Sorry guys, but i would like to make things clearer, As I mentioned earlier, What i'm doing is the following: 1) Using the Jfilechooser, save the results into a filename.txt file _[main class in the manifest file (class for the GUI) ]._ 2) Click "run" to write the data to the created file in step 1 [_another class is used to write to file_]. I have a feeling that the problem is related to the manifest main class. What do you think guys?I think your description of the problem is very bad. And I think your idea of making wild guesses is a bad way of diagnosing problems.
    First of all. A JFileChooser does not save anything. It just allows the user to select a file to be saved to. So if you thought that the first step was writing anything or creating any file, you're probably wrong. But examining the code would help you understand.
    Second, if you're having problems because one class chooses the file name and a second class writes data to it, then you're probably running into the basic beginner problem we see around here all the time of how to communicate data between objects. Again, examining the code might help.
    Third, you need to understand what is writing that error message. Examining the code would help there too.
    So: stop guessing. Look at the code.I'm still New To Java that's why i find difficulty in problems diagnosis. Regarding the JAR problem, as you mentioned, I used JFileChooser to select a file and (copying data) is the other part. So I will look at the code again.
    Edited by: Eng.Sh_2004 on Aug 26, 2010 1:10 PM

  • File Sharing not working properly on app

    Hello,
    My group has been developing an app that will run on an iPad for a company and the app needs to add or edit documents (in pdf format) to the app through itunes. We've implemented UIFileSharingEnabled in the info.plist and the app appears on iTunes that it can support file sharing. Now the problem is when we add files to the app, the files don't appear in the app itself and we've searched trying to find out what could be causing this but we're not sure what's going on.

    What code have you written in the iPad app to allow the files added via iTunes to 'appear' there?

  • Why is my Acer "Ab Files" program not working properly when I download it to my Acer Aspire One?

    Hello there, Im having an issue with trying to download Acers Ab files that works with the apps for Iphone. When I do download it and I click on it, my screen goes black for a second and then everything on my screen gets huge like its in SAFE MODE. I've tried to uninstall it and it keeps doing the same darn thing. I've checked for recent updates for windows and spy and malware and any corrupt files using a program that detects and fixes them. It comes up clean. This program used to work on my computer and now it doesn't. So far, I think its the only one that works convienently using wireless, unless theres another app that does the same. Anyone have this problem? Thanks....

    Charliewhitepaw,
    When you say this program used to work on your computer, what has changed since then? Have you attempted to go back (system restore) to when it worked to see if that resolves the issue?

  • I am new to mac air. Today i installed (unsuccessfully!) MAPLE16 on my mac book air. Now since it does not work properly (it also does not appear in  applications) i decide to delete it. I could not remove it from launchpad . i need urgent help

    i am new to mac air. Today i installed (unsuccessfully!) MAPLE16 on my mac book air. Now since it does not work properly (it also does not appear in  applications) i decide to delete it. I could not remove it from launchpad . i need urgent help from your side.

    Any third-party software that doesn't install by drag-and-drop into the Applications folder, and uninstall by drag-and-drop to the Trash, is a system modification.
    Whenever you remove system modifications, they must be removed completely, and the only way to do that is to use the uninstallation tool, if any, provided by the developers, or to follow their instructions. If the software has been incompletely removed, you may have to re-download or even reinstall it in order to finish the job.
    I never install system modifications myself, and I don't know how to uninstall them. You'll have to do your own research to find that information.
    Here are some general guidelines to get you started. Suppose you want to remove something called “BrickMyMac” (a hypothetical example.) First, consult the product's Help menu, if there is one, for instructions. Finding none there, look on the developer's website, say www.brickmyrmac.com. (That may not be the actual name of the site; if necessary, search the Web for the product name.) If you don’t find anything on the website or in your search, contact the developer. While you're waiting for a response, download BrickMyMac.dmg and open it. There may be an application in there such as “Uninstall BrickMyMac.” If not, open “BrickMyMac.pkg” and look for an Uninstall button.
    You generally have to reboot in order to complete an uninstallation.
    If you can’t remove software in any other way, you’ll have to erase and install OS X. Never install any third-party software unless you're sure you know how to uninstall it; otherwise you may create problems that are very hard to solve.
    You may be advised by others to try to remove complex system modifications by hunting for files by name, or by running "utilities" that purport to remove software. I don't give such advice. Those tactics often will not work and maymake the problem worse.

  • Ive just upgraded my late 2009 macbook, and things are not working properly. First of all, when I started the computer first time after installing Mountain Lion, some message advised me that some files were impossible to install.

    Ive just upgraded my late 2009 macbook, and things are not working properly. First of all, when I started the computer first time after installing Mountain Lion, some message advised me that some files were impossible to install. Once I wrote my password, and for now on, everytime I start the session, another window advise me that "Java SE 6" is missing, due that, the computer can't run some "CS5Service Manager". If I try to install it, the download ends with an error. If finally, you skip the istallation, you arrive to the dock, but the menu bar at the top of the screen doesn't show up.
    In addition, my trackpad doesn't works either. I can move the arrow but i can't click anywhere, probably because the option of clicking by touching is disabeled and I can't performance a regular click.
    I'll be very glad if someone know what the heck is happening with my computer. Anyway, I'm going to the genius bar next Saturday. Thx!

    We're sorry.
    We can't find the article you're looking for.
    Please return to the Apple Support homepage.
    Sigh.

  • Pick activity is not working properly while creating two or more file adapt

    Hi,
    pick activity is not working properly while creating two or more file adapter for bpel process.
    bpel process compiled and deployed succesfully but while observing the wsdl file of deployed process you can find only one file adapter. so it polls only from that location.
    can anybody help on over this? or it's limitation of jdev to use only one file adapter at time while using Pick.
    Thanks
    sagar

    Does anybody tried this?
    Thanks
    sagar

  • SWF file not working properly in Explorer

    I have made a kind of slide show showing jpg images loaded
    from the web in an swf file, and it will not work properly. It is
    my first .swf application, and I am using the free downloadable
    FlashObject.js to load the swf into the browser. The problem is
    that it sometimes loads perfectly, while other times it will not
    work at all! It is not the paths, because I have tried setting the
    images in the same directory as the swf, and not importing the
    image names thru flashVars. What drives me mad is that it works
    consistently in Explorer, the first time I load it, and the first
    time after I have cleared the temporary internet files. Otherwise
    it will not load at all. In Firefox however, if randomly fails to
    load about one time out of ten or something like that. The code is
    compiled using the free downloadable compiler. Anyone have any idea
    what may be wrong?

    I may be late but better late then...
    Not true
    You can nest hundreds of layers as long as all symbols are graphics.
    People try to use a Movie symbol and this is script executed.
    I am animator on cartoon all done in flash and we have dozens or more NESTS!!!!
    Eyes inside of head inside of Character in car on stage...
    many
    Trick to not crashing is in FLASH
    Set publish settings to FLASH 8.
    Never use FLASH 9 with Actionsscript 3... This adds a lot of instability.
    1 of these swfs in a project could kill it.
    I render SWF at 30fps at 1920x1080 then into AE, then scale down to SD wide screen resolution 720x480 16x9.. set scale to 45.5 x 44.5 percent.
    I output final animation at Quicktime ANIMATION 100 millions of colors... 1.21 (16x9)audio added at 48k
    I have hundreds of hours trying to make this work reliably and finally I got the mix.
    Then I take QT to Premiere for final edit, audio and titles.
    Good luck
    NATMAX

  • I bought creative suite cs6 design standard student and teacher edition and the download did not work properly - files appear incomplete/ or damaged - none of the program items work at all. File size for installation seems very small for a product of this

    I bought creative suite cs6 standard student and teacher edition and the download did not work properly - files appear incomplete/ or damaged. File size seems very small for a product of this size. Can you assist with download issue or provision of software ?

    Lalalaladog where did you download CS6 from?  I would recommend downloading the installation files for Creative Suite 6 Design Standard at Download CS6 products

  • I had to restore my computer. After reinstalling itunes and sincronizing with my ipod, the music files were not organized in itunes as in the ipod: some songs were missing, some albums has no cover? Why is the sincronization not working properly?

    I had to restore my computer. After reinstalling itunes and sincronizing with my ipod, the music files were not organized in itunes as in the ipod: some songs were missing, some albums has no cover? Why is the sincronization not working properly?

    See Recover your iTunes library from your iPod or iOS device.
    tt2

Maybe you are looking for