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

Similar Messages

  • Set.contains returns false even when the set contains the element

    As per java documentation, set.contains(o) returns true if and only if this set contains an element e such that (o==null ? e==null : o.equals(e)). In my case it doesn't (I have tested with Java 1.50_09 and Java 1.6.0). Look at the small toy example below. The last assert statement fails. But as per the documentation, it should not, since an element sc exists in the set such that sc.equals(sc2).
    Any help will be greatly appreciated.
    thanks
    Nilesh
    import java.util.HashSet;
    import java.util.Set;
    class StringCapsule {
        String s;
        public StringCapsule(String s) {
            this.s = s;
        public boolean equals(StringCapsule s2) {
            return s.equals(s2.s);
    public class TestSets {
        public static void main(String[] args) {
            Set<StringCapsule> set = new HashSet<StringCapsule>();
            String s = "test";
            StringCapsule sc = new StringCapsule(s);
            StringCapsule sc2 = new StringCapsule(s);
            set.add(sc);
            assert (set.contains(sc));
            assert (sc.equals(sc2));
            assert (set.contains(sc2)); // THIS FAILS
            System.out.println("Finished with set size " + set.size());
    }Copy above code to TestSets.java, and compile and run to reproduce
    javac TestSets.java
    java -ea -cp . TestSets

    If you have generics available, you should have annotations as well. One way to avoid this kind of problem in the future is to use
    @Override
    public boolean equals (Object o) when you know you want a method to override it's parent.

  • The printing of .pdf file from Project 2013 stops when the file name should be written. Project 2013 crashes. Does someone know what is wrong between Project 2013 and Adobe Acrobat 9?

    The printing of .pdf file from Project 2013 stops when the file name should be written. Project 2013 crashes. Does someone know what is wrong between Project 2013 and Adobe Acrobat 9?

    The Acrobat 9.x product family passed into "End of Support" mid-year of 2013.
    Acrobat 9 support of MS Project via PDFMaker stops with Office 2007.
    For Office 2013 support you must use Acrobat XI (11.0.1) or newer. 
    A good to have reference:
    https://helpx.adobe.com/acrobat/kb/compatible-web-browsers-pdfmaker-applications.html
    Acrobat Pro and Standard DC are what are currently available for purchase. 
    Be well...

  • Sender file communication channel polling only when the file is written

    Hi guys,
    I have the following scenario:
    I have developed an XI interface that takes a .txt file from SAP R/3's file system, usr/sap/trans/ and delivers it into another ftp location. The problem that we face is that the file is written into source directory from an ABAP program. As a result, XI go and polls into source directory when the file is not completely written, or when it is empty, which blocks the process.
    Is there a way to force XI in order to poll the source directory only when the file is complete?
    We have thought of exporting the file into a name that XI does not expect and as soon as the file is complete to rename the file from inside ABAP program into what XI expects.
    However, the command inside ABAP changed the Code page of the file and we cannot see some special characters in the file that is delivered to the ftp location.
    Any ideas??

    Hi Evaggelos,
    from <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm">SAP help: Configuring the Sender File/FTP Adapter</a>:
    Advanced Mode
    To specify additional parameters in the adapter configuration, set the Advanced Mode indicator.
    &#9679;      Msecs to Wait Before Modification Check
    Enter the number of milliseconds that the adapter must wait before it checks whether the files have been changed
    Regards,
    Udo

  • ITunes keeps storing files on C drive, even when the library/storage is on another internal drive. It should stop that.

    Whatever I do to get iTunes to store it's data and settings on another internal drive, it KEEPS some sort of data/settings stored on the C drive.
    A mkdir has been set up already to catch nasty "keep doing that" behaviour. Nevertheless, iTunes dumps stuff on the C drive /documents/mymusic.
    Without to receive a technical story (read: a SIMPLE solution that does not feel like a hack), what's the solution.
    Why does iTunes not simply ask WHERE to store the files rather than "assuming that the user is stupid and we think for him" attitude.
    managing a database or DRM isn't THAT difficult.
    Whatever files are within the directory is absolutely fine, as long as the user is allowed to choose that directory.

    Did you mean mkdir or mklnk?
    By default the iTunes library is stored at C:\Users\<User>\Music. If you play with Windows so that your entire profile is stored on a different drive then the library will be stored inside the profile. If you have used the option to change the location of the media folder to point to another path then you've only changed where the content is stored, not the database and supporting files. In addition if you use this option with an external drive or network share and that location isn't ready when iTunes starts then it will reset the path to the media folder to the default location inside the library folder.
    Generally the solution when setting out is to move the entire library to the root of a different drive and then shift-start-iTunes to connect to the library in this new location. See HT1589: iTunes: How to open an alternate iTunes Library file or create a new one
    Since you didn't do that to start with, either start again, or see my post make a split library portable.
    There is another chunk of data stored in the %appdata% section of your user profile. If you don't have any iOS devices you can ignore this, but if you have, and have an SSD system drive, then there is merit in relocating the ...\MobileSync\Backup folder to another drive with a mklnk junction/symbolic link as these backup folders can become quite large. Note that junctions/links should not be used to relocate sections of the main library as they will be unraveled if iTunes ever tries to write to the path.
    tt2

  • Viewing AI file in ID as cmyk when the file is rgb. Why?

    I've upgraded from CS5 to CS6 and this is the first time I'll have used Illustrator. I've worked on an rgb file that I downloaded from iStock. I saved it as an rgb file but before I saved the file, I viewed the vector image in cmyk mode just to see what it would look like. I closed the file and opened my document in ID that I wanted to place my AI file into. When I placed it into the ID document, it imported as a cmyk file. I wouldn't have known what had happened if I hadn't viewed it as a cmyk file when I had saved it in Illustrator. I've never experienced this before so am curious as to why this is happening. I'm working in OS10.8.2 on a Mac Pro tower (whether this makes any difference or not, I don't know, but I've been asked these questions before when coming to the forums.) I've seen on other posts this is a color management glitch in CS6. Has there been a fix? Or is there some other bug?

    How do you 'view' the file? A SWF file is meant to be launched from its companion HTML file (name.htm) which will call the JS and CSS files and then launch the SWF.
    Do you see the playbar when you Preview in Browser (F12)? Can you check version number: 8.0.1.242 is the present version of 8.

  • Cannot open any files in Adobe CS6 even though the files were created in cs6

    I am currently using Adobe cs6 I cannot get any of my old files to open do anybody know of any possible issues that may have been experienced with this program please help

    Hi there,
    Are you able to open the file in Acrobat? If so, try saving it as a .PDF then see if you can open the PDFs in Illustrator.
    Otherwise, the files might be corrupted.
    - Amy

  • Unresolved Rule: Even when the rule exists in rule library.

    Hi,
    I have a rule called getSAProles sitting in RuleLibrary. When I try to open the form in BPE I get an error Error rendering form:comwaveset.util.WavesetException: Unresolved rule: RuleLibrary :getSAProles
    Does any one know why? I have the rule in my repository. I have tried importing the rule a bunch of times.
    Thanks

    Does it specify the name of the rule? Usually when I get this error it tells me specifically which rule it cannot find, then it can be added or the reference typo can be fixed, etc...

  • 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

  • I somehow changed a video in my imovie to zero fps, so it just plays black.  The video still exists on my desktop but even when I delete the files from imovie and reimport them the file is still in zero fps and play black.

    somehow changed a video in my imovie to zero fps, so it just plays black.  The video still exists on my desktop but even when I delete the files from imovie and reimport them the file is still in zero fps and play black.

    I'm not sure of your question.
    Are you asking how to use Photoshop?
    Or are you asking for the dimensions of video iMovie uses?
    It edits in 720P HD, which is 1280x720.
    You can make it a bit bigger so you can zoom in.
    Much bigger then this is a waste of time.

  • 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

  • Why can I not attach a document to an email? Every time I want to send an email with a document attached to it, an error notice pops out. It tell me that the file is being used even when  it is not. How can I fix this issue?

    Why can I not attach a document to an email? Every time I want to send an email with a document attached to it, an error notice pops out. It tells me that the file is being used even when  iall other programs are closed. How can I fix this issue?

    Thanks Jeff, I was not aware that a template could be multi-page.  (All the existing templates were 1 page)
    But it worked, saving me some steps.  When I was finished I renamed the document, and locked it.
    Then tried to save it but  could not because it was locked.  I closed it, went to my Spread Sheet Folder ,
    to find it, it was not there.  The Finder could not find it either.
    So I start over again.
    I opened up Numbers and it showed my personal Numbers template folder, it contained both my new 
    original 4 page template and the vanished saved document!
    I tried to delete the template containing these document data and could not - I had to go to the Library/Application Support/Numbers to physically remove it from this folder. Then I started over again.  I Finally found out how to make it work: I can now "save as", and then lock, and it will go to place where I want it to be saved and locked.
    The secret is: Click on the document title in the menu bar, and it opens up  "Save as...", which works the same as in OS 10.4.11, and you can pick the place you want for saving.  Once done that, you can then lock the document in the same pull down menu, and then close it.
    I also found later that I can delete a template from its folder, by letting Numbers open the templates,
    clicking on the one I want to remove, then go to the "Numbers Menu/File/Move to...", select "Desktop"
    and from there the selected template can then be thrown into the Trash from there.
    It appears now that the real fault of the Numbers software is that the "Save as" command is not available in the "Edit" or "File" pull-down menus, but hidden behind the title of the document.

  • Save as does not Create PDF Compatible File even when the creare pdf compatible files is on, Illustrator CC 2014

    save as does not Create PDF Compatible File even when the creare pdf compatible files is on, Illustrator CC 2014

    When I open is adobe acrobat I get this message.
    "This is an Adobe® Illustrator® File that was
    saved without PDF Content.
    To Place or open this  le in other
    applications, it should be re-saved from
    Adobe Illustrator with the "Create PDF
    Compatible File" option turned on. This
    option is in the Illustrator Native Format
    Options dialog box, which appears when
    saving an Adobe Illustrator  le using the
    Save As command."

  • While using a drop-down menu i.e. File, edit, image, or even when saving as and choosing the file type; the list appears and I am able to highlight what i want but cannot click on anything.

    While using a drop-down menu i.e. File, edit, image, or even when saving as and choosing the file type; the list appears and I am able to highlight what i want but cannot click on anything. This is becoming incredibly frustrating. It happens at random time and a restart of the computer is all that helps, then with out any notice it starts to do this again.  Mac Book Pro i7 2.2 16 GB 1333 Ram, (2) 450GB SSD both internal to machine. At this point I am losing file because I am unable to save in the file type I need. Does anyone out there know how to solve this issue?
    Thanks
    phil

    I haven't been unify photoshop much in the past month, but I did try your suggestion and it seemed to work for a while. Today when i went to save a document the same thing happened: click on file>save at this point I can not click on save even though it is highlighted. Tryed to use command s that brings up the save dialogue box, but when I try to change file type I again cannot select it from the drop down menu.

  • Cant get list of files from a folder (even though the folder and files are created with the same app)

    Ok so each character rolled with my app gets saved as an html file in a folder i create on the sdcard called RpgApp
    the code to do this is 
    private async Task saveToHtmlCharacter(string name)
    StorageFolder externalDevices = Windows.Storage.KnownFolders.RemovableDevices;
    StorageFolder sdcard = (await externalDevices.GetFoldersAsync()).FirstOrDefault(); //Windows.Storage.ApplicationData.Current.LocalFolder;
    var dataFolder = await sdcard.CreateFolderAsync("RpgApp",
    CreationCollisionOption.OpenIfExists);
    var file = await dataFolder.CreateFileAsync(name+".html",
    CreationCollisionOption.ReplaceExisting);
    using (StreamWriter writer = new StreamWriter(await file.OpenStreamForWriteAsync()))
    writer.WriteLine("<html><head><title>Character File for " + z.charNameFirst + " " + z.charNameSecond + "</title></head><body>");
    //trimed for the post
    now this as i say works perfectly and i can confirm that the files show up in the "RpgApp"folder
    now the next step is to have the app read the names of each of those html files and create a seperate button for each one named for the filename and with the filename as content (later i will link them up to load the html file they are named for in a webbrowser
    panal)
    here is the code that *should* do that
    private async Task readFiles()
    z.test.Clear();
    StorageFolder externalDevices = Windows.Storage.KnownFolders.RemovableDevices;
    StorageFolder folder = (await externalDevices.GetFolderAsync("RpgApp"));
    IReadOnlyList<StorageFile> fileList = await folder.GetFilesAsync();
    //z.test.Add("dummy");
    foreach (StorageFile file in fileList)
    z.test.Add(file.Name);
    public async void buttonTest()
    await readFiles();
    CoreDispatcher dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
    await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    foreach (string name in z.test)
    Button button1 = new Button();
    button1.Height = 75;
    button1.Content = name;
    button1.Name = name;
    testStackPanal.Children.Add(button1);
    now i say should as what i get is an error of "A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.ni.dll" (2 of them in fact one after another)
    more detailed error is at http://pastebin.com/3hBaZLQ9
    now i went through checking line after line to find the error and line that causes it is:
    StorageFolder folder = (await externalDevices.GetFolderAsync("RpgApp"));
    in the readFiles method
    i checked to make sure the case is right etc and its spot on, that IS the folder name, and remember my app creates that folder and creates the files that are inside that folder (and only files my app creates are in that folder) so it should have access
    im 100% stuck its taken me all day to get the files to save and now i cant get them to list correctly
    I have tested the button creation function with fake list data and that worked fine, as i say the error is when i tell it to look at the folder it created
    all help most greatfully recieved

    this was actually solved for me on another forum thread 
    async Task<bool> continueToReadAllFiles(StorageFolder folder)
    if (folder == null)
    return false;
    if (folder.Name.Equals("RpgApp", StringComparison.CurrentCultureIgnoreCase))
    var files = await folder.GetFilesAsync();
    foreach (var file in files)
    test.Add(file.Name);
    return false;
    var folders = await folder.GetFoldersAsync();
    foreach (var child in folders)
    if (!await continueToReadAllFiles(child))
    return false;
    return true;
    public async void buttonTest()
    test.Clear();
    StorageFolder externalDevices = Windows.Storage.KnownFolders.RemovableDevices;
    var folders = await externalDevices.GetFoldersAsync();
    foreach (var folder in folders)
    if (!await continueToReadAllFiles(folder))
    break;
    //.... commented out
    ...now i say solved this is more a workaround...but it works.
    I would love to know why we cant just scan the RpgApp folder instead of having to scan the whole dc card and disregard all thats not in the RpgApp folder

Maybe you are looking for