File.exists() returning false eventhough in reality the file exists

Hi,
I am trying to create a PDF file using FDFMerge software.
For creating the PDF file, I need to execute a shell script from command-line, which I am doing using "Runtime.exec".
( I opted for this 'RunTime.exec' approach so as to read the output generated by the shell script.)
After executing the shell script and reading all the output generated by the process, I am trying to check if the PDF file exists in the location the process created.
When I do File.exists() its returning me "false" eventhough in reality the file exists.
Any guess, why this is happening?
Thanks in advance.
-Sudheer

Hi,
I am trying to create a PDF file using FDFMerge
software.
For creating the PDF file, I need to execute a shell
script from command-line, which I am doing using
"Runtime.exec".
( I opted for this 'RunTime.exec' approach so as to
read the output generated by the shell script.)
After executing the shell script and reading all the
output generated by the process, I am trying to check
if the PDF file exists in the location the process
created.
When I do File.exists() its returning me "false"
eventhough in reality the file exists.
Any guess, why this is happening?
Thanks in advance.
-SudheerI know the following method works for checking if a file exists...
public LineCounterB1()
          super( "GUI File reader" );
          tField = new JTextField("c:..\\FileScanner\\source\\test\\LineCounterB1.java");
          tField.setBackground(backColor1);
          tField.setForeground(foreColor1);
          tField.addActionListener( this );
public void actionPerformed( ActionEvent ae )
          File name = new File( ae.getActionCommand() );
          if( name.exists() )
               oArea.setText("FOUND " + name.getName() + "\n" +
                    (name.isFile() ? "File\n" : "Not a File\n" ) +
                    (name.isDirectory() ? "Directory\n" : "Not a Directory\n" ) +
                    (name.isAbsolute() ? "Absolute path\n" : "Not Absolute path\n" ) +
                    "Last modified" + name.lastModified() );
               if( name.isFile() )
                    try
                         BufferedReader reader = new BufferedReader( new FileReader( name ) );
                         StringBuffer buffer = new StringBuffer();
                         String text = null;
                         oArea.append("\n\n");
                         while((text = reader.readLine())!=null)
                              buffer.append(text + lineSep);
                         oArea.append(buffer.toString());
                    catch( IOException ioE)
                         JOptionPane.showMessageDialog(null,"Oooooo...");
                    //S7 scanner7 = new S7(/**name**/);                                        
               else if( name.isDirectory())
                    String directory[] = name.list();
                    oArea.append("\n\nDir contents:\n");                    
                         for( int i=0; i<directory.length; i++)
                              oArea.append( directory[i] + "\n");
          else
               JOptionPane.showMessageDialog(null, "No such file or directory.");
     }

Similar Messages

  • File.exists() returns false even when the file exists

    hi,
    the exists() function of java.io.File function returns false even when the file exists on the file system. why is this? i checked the path of the file which gives me the correct path, but exists returns false. can anyone help?

    post some of the code you�re using - then maybe I can help you out
    //Anders

  • File.exists() returns false for existing file, help :)

    Hi all,
    I'm having the STRANGEST behavior... I'm working on a simple DNS management system, and before I overwrite a zone file, I want to check if it exists... but exists() is returning false even when the file exists.
    Here is my code snippet:
    finest( "Checking the existance of "+filename ) ;
    File zoneFile = new File( filename ) ;
    if ( zoneFile.exists() ) {
        finest( "Zone File "+zoneFile+" already exists." ) ;
        throw( new ZoneFileExistsException( fqdn ) ) ;
    else {
        finest( "Creating Zone File "+zoneFile ) ;
        ...It's producing this in the log (I cut off the timestamp parts):
    Checking the existance of /opt/DNS/db.testingbutler222.com
    Creating Zone File /opt/DNS/db.testingbutler222.com
    but...
    # ls -l /opt/DNS/db.testingbutler222.com
    -rw-r--r-- 1 root other 733 Aug 27 19:23 /opt/DNS/db.testingbutler222.com
    So... as you can see, the file CLEARLY exists... what the heck am I doing wrong or misunderstanding? This can't really be a bug in File, can it?
    Kenny Smith

    Hi,
    Thanks for your response, but as I showed in my first post, I'm using absolute paths. My log file contains this:
    Checking the existance of /opt/DNS/db.testbutler222.com...
    Existance of /opt/DNS/db.testbutler222.com=false
    # ls -l /opt/DNS/db.testbutler222.com
    -rw-r--r-- 1 root other 695 Aug 29 12:17 /opt/DNS/db.testbutler222.com
    I don't understand what is happening... I wrote a separate class that just tests the existance of a file, and that one is reporting the existance correctly.... (the source code is found in the second post above) I don't understand why my servlet code can see the file.
    I have jakarta-tomcat running as root, and the file I'm checking was created by the same servlet. I've double checked permissions and such, just to make sure it wasn't that.. but it's still not working.
    I even added code to create a FileReader from the file, that way if it throws a FileNotFoundException, I would know the file doesn't exist... and even though the file does exist, it throws the exception. :(
    Kenny

  • File.exists returns false

    File.exists returns false if the File object represents a symlink that is pointing to a non existing file.
    How can I make it return true? I am using File.exists in a condition to
    check if a symlink exists before calling File.delete.
    I am using JDK 1.1.8.
    Any help is appreciated.
    Anil

    Interesting. But it doesn't hurt to call delete() even the File doesn't exist, does it? Could you clarify why you need to confirm that before calling delete()?
    PC

  • Cannot make a cache safe URL for "1025/styles/Themable/corev4.css", file not found. Please verify that the file exists under the layouts directory.

    HI
    i restored a sharepoint web 80 application in our test domain
    and after when i browse the new web application 
    it says 
    Cannot make a cache safe URL for "1025/styles/Themable/corev4.css", file not found. Please verify that the file exists under the layouts directory. 
    adil

    Hi  adil,
    According to your description, my understanding is that you encountered the error “Cannot make a cache safe URL for "1025/styles/Themable/corev4.css", file not found. Please verify that the file
    exists under the layouts directory.” .
    The issue happens in
    We have customized master page
    In the master page, we use path the script/style file like this: <SharePoint:CssRegistration name="<% $SPUrl:~SiteCollection/Style Library/coe/mainCOE.css%>"
    runat="server"/>
    While using the dynamic path in a multiple languages enabled site, language Id(1033 etc) will be added to the path automatically. That cause the file to be not found.
    To solve the issue, please download  the Arabic language pack http://www.microsoft.com/en-us/download/details.aspx?id=3411 ,
    install it on  your SharePoint and refresh your browser.
    Reference:
    http://sharepoint-community.net/profiles/blogs/cannot-make-a-cache-safe-url-for-1036-sytles-themable-corev4-css
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Hi thee.  As logical as I can be.  I export a file back into my folder as a PSD.  I then export that file to PS.  Work on it, save and return it to LR.  The file goes to the bottom of the folder from where I have to put it back in the original place, taki

    Hi thee.  As logical as I can be.  I export a file back into my folder as a PSD.  I then export that file to PS.  Work on it, save and return it to LR.  The file goes to the bottom of the folder from where I have to put it back in the original place, taking time and driving me slightly mad.  Why does the file not go back to where it came from please?  Thanks  Tim

    Umm, but this folder is an amalgam of two cameras and five cards, and I want them in capture order!  Thanks for trying though Jim.
    Cheers
    Tim

  • How to search a special string in txt file and return it's position in txt file?

    How to search a special string in txt file and return it's position in txt file?

    I just posted a solution for a similar question here:  http://forums.ni.com/ni/board/message?board.id=170​&view=by_date_ascending&message.id=362699#M362699
    The top portion can search for the location of a string, while the bottom portion is to locate the position of a character.  Both can search for a character.
    The position of the character within the file is displayed in the indicator(s).
    R

  • The File name property is not valid. The file name is a device or contains invalid characters

    I have an SSIS task that has run successfully for years. They just moved the dtsx to a new server and now it is failing. 
    Issue:
    The task has a data flow that writes a raw file destination. It then has a subsequent data flow that reads the raw file destination. 
    The path and name of the raw file is passed to each of the data flows via the same variable. 
    The raw file resides in a folder on the server in the same path that the dtsx resides in. 
    The task fails with the "The File name property is not valid. The file name is a device or contains invalid characters" error when trying to access the raw file.
    What we have done to troubleshoot:
    1. I ran the task successfully on my local machine so it is definitely a server issue.
    2. The first thing we were seeing was that it failed trying to write to the raw file. The task is set to "Create Always". 
    3. We saw that the dba's copied over the entire directory structure from the old server which included a previously created raw file, so we deleted the raw file.
    4. We reran the task and it successfully wrote a new raw file but then failed on reading the raw file with the same error as above.
    5. We reran the task AGAIN and this time it failed trying to write the raw file throwing the same error as above.
    6. The dba looked at the directory and the account that performs the task has full control.
    7. The dba looked at the raw file that was created and verified that the account that performs the task has full control of the file and that it is the owner of the file.
    Summary:
    The task fails when trying to access the file EXCEPT when the file does not exist. In that situation it can write the file but subsequently fails in accessing it again.

    Hi Whalensdad,
    Based on my research, the issue can be caused by the following reasons:
    There are some invalid characters in the File name at package runtime. In this scenario, just as Russ said, could you please post the value that is in the File name variable? Also use a Script Task with Messagebox.show to show the variable values at runtime.
    May be it changes to others at run time.
    The account runs the package not having access to all the folders in the path. Since you are moving the dtsx file from one server to the current server, do you also move the raw file to the same folder in the current server? Does the user runs the package
    have access to all the folders in the path? To solve this, please ensure that the user has access to all folders and the raw file in the path on the current server.
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support
    Please see the response above. I can't use a message box on a server so I logged the values to the database. The resource account has full control to the folder. I haven't been able to get the DBA to check the SQL Agents permissions, but I was always under
    the impression that if you use "Run As" on the task, it will not use the SQL Agent but the account you identify it to "Run As". The "Run As" account has full control on the folder and file.

  • File repository server error: failed to put the file to file server

    Hi,
    Am trying to export relational and OLAP universe to repository and getting an error.
    Am using Universe Design Tool and product version is  BI 4.0 SP 5
    When I create a universe and export it for the first time it get exported successfully.
    However I tried to export same universe after making few changes, getting below error
    File Repository Server error: Failed to put the file to fileserver: frs://<FRS Location>/Universe_Name.unv already exists
    Is anybody faced such issue?
    I suspect it is a configuration issue/product bug.
    Your thoughts are highly appreciated.
    Regards,
    Vinesh

    Hello Vinesh,
    There is a workaround mentioned in the following KBA:
    1309859 - Error: WIS 00501 Universe not found when viewing Documents
    Please have a look.
    Thanks and regards,
    Madhumitha

  • I am running out of memory on my hard drive and need to delete files. How can I see all the files/applications on my hard drive so I can see what is taking up a lot of room?

    I am running out of memory on my hard drive and need to delete files. How can I see all the files/applications on my hard drive so I can see what is taking up a lot of room?
    Thanks!
    David

    Either of these should help.
    http://grandperspectiv.sourceforge.net/
    http://www.whatsizemac.com/
    Or search 'disk size' in the App Store.
    Be carefull with what you delete & have a backup BEFORE you start, you may also want to reboot to try to free any memory that may have been written to disk.

  • I have tried a lot to find an app or some way in email to attach multiple of pdf files in one email. I could not find anything that sends multiple pdf file in one email and still keeping the file in simple pdf format for the recipient.

    I have tried a lot to find an app or some way in email to attach multiple of pdf files in one email. I could not find anything that sends multiple pdf file in one email and still keeping the file in simple pdf format for the recipient.

    I am not aware of a way except for photos that allows you to select multiple files in an email. I even checked settings in the Adobe Reader app, and it does not show that ability.

  • If you delete files from your computer, BlackBerry Link deletes the file or collection from your device?

    I found the below description from the help of BlackBerry Link, however i never get it work.
    Any one know whats wrong or what i need to set?
    About deleting music, pictures, videos, and documents?
    After you sync your music, picture, video, or document files between your computer and your BlackBerrydevice, if you delete a file or a collection of files, the following actions occur:
    If you delete files from your computer, BlackBerry Link deletes the file or collection from your device.
    If you delete files from your device, BlackBerry Link doesn't delete the file or collection from your computer.
    For information about how to delete a file from your device, tap the Help app on the home screen of your device.

    Hey hkfoolman,
    Welcome to the BlackBerry Support Community Forums.
    Thanks for the question.
    Go into BlackBerry Link and click on the BlackBerry and then click on Options.  Make sure you have Music, Pictures, Videos and Documents checkmarked for synchronization.  Once these are checked, try to remove the files.
    Let me know if you have any more questions.
    Cheers.
    -ViciousFerret
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Like! for those who have helped you.
    Click  Accept as Solution for posts that have solved your issue(s)!

  • I am running InDesign CS5.5 and trying to open an In Design File but getting an error message. " Cannot open the file "PDavidLCover.indd". Adobe InDesign may not support the file format, a plug-in that supports the file format may be missing, or the file

    I am running InDesign CS5.5 and trying to open an In Design File but getting an error message. " Cannot open the file "PDavidLCover.indd". Adobe InDesign may not support the file format, a plug-in that supports the file format may be missing, or the file me be open in another application."Please help I really need to get this file open.

    Since you've shown us the folder contents it's a good bet it isn't in use (no lock file). And it doesn't look like the file is mis-named as there doesn't seem to be anything else there that would be the .indd file (but just in case, open it in TextEdit and paste the first few lines here so we can see what the file header says), so the most likely case is the file is damaged. Is that on a removable device of some sort?
    You can try the tool at Repair corrupt InDesign Adobe files on Mac OS X  or send me a link to the file by private message and I'll try the recovery tool I have for Windows.

  • Itunes 10.6.1.7 problem: when I change the file "media type" from 'Music' to 'Podcast' the file disapears from ITUNES. I do this via (1) right click, (2) select 'Get Info', (3) select 'options' tab, and (4) change media type. What is the problem?

    Itunes 10.6.1.7 problem: when I change the file "media type" from 'Music' to 'Podcast' the file disapears from ITUNES. I do this via (1) right click, (2) select 'Get Info', (3) select 'options' tab, and (4) change media type. What is the problem?

    Hi Memalyn
    Essentially, the bare issue is that you have a 500GB hard drive with only 10GB free. That is not sufficient to run the system properly. The two options you have are to move/remove files to another location, or to install a larger hard drive (eg 2TB). Drive space has nothing to do with SMC firmware, and usually large media files are to blame.
    My first recommendation is this: download and run the free OmniDiskSweeper. This will identify the exact size of all your folders - you can drill down into the subfolders and figure out where your largest culprits are. For example, you might find that your Pictures folder contains both an iPhoto Library and copies that you've brought in from a camera but are outside the iPhoto Library structure. Or perhaps you have a lot of purchased video content in iTunes.
    If you find files that you KNOW you do not need, you can delete them. Don't delete them just because you have a backup, since if the backup fails, you will lose all your copies.
    Don't worry about "cleaners" for now - they don't save much space and can actually cause problems. Deal with the large file situation first and see how you get on.
    Let us know what you find out, and if you manage to get your space back.
    Matt

  • When I try to import pictures from media card to iPhoto, I'm getting the error 'The following file could not be imported. The file is in an unrecognized format.'  The file is a jpeg and I've never had this problem before.

    When I try to import pictures from media card to iPhoto, I'm getting the error 'The following file could not be imported. The file is in an unrecognized format.'  The file is a jpeg and I've never had this problem before.

    What version of iPhoto?
    What colour profile is the shot?
    As a Test:
    Hold down the option (or alt) key and launch iPhoto. From the resulting menu select 'Create Library'
    Import a few pics into this new, blank library. Is the Problem repeated there?

Maybe you are looking for