cdm/src/main/java/ucar/nc2/util/DiskCache.java
static public File getFile(String fileLocation, boolean alwaysInCache) {
    if (alwaysInCache) {
      return getCacheFile(fileLocation);

    } else {
      File f = new File(fileLocation);
      if (f.exists())
        return f;

      // now comes the tricky part to make sure we can open and write to it
      try {
        if (!simulateUnwritableDir && f.createNewFile()) {
          boolean ret = f.delete();
          assert ret;
          return f;
        }
      } catch (IOException e) {
        // cant write to it - drop through
      }

      return getCacheFile(fileLocation);
    }
  }
static public File getFile(String fileLocation, boolean alwaysInCache) {
    if (alwaysInCache) {
      return getCacheFile(fileLocation);

    } else {
      File f = new File(fileLocation);
      if (f.exists())
        return f;

      // now comes the tricky part to make sure we can open and write to it
      try {
        if (!simulateUnwritableDir && f.createNewFile()) {
          boolean ret = f.delete();
          assert ret;
          return f;
        }
      } catch (IOException e) {
        // cant write to it - drop through
      }

      return getCacheFile(fileLocation);
    }
  }
static public File getFile ( String fileLocation , boolean alwaysInCache ) { if ( alwaysInCache ) { return getCacheFile ( fileLocation ) ; } else { File f = new File ( fileLocation ) ; if ( f . exists ( ) ) return f ; // now comes the tricky part to make sure we can open and write to it
 try { if ( ! simulateUnwritableDir && f . createNewFile ( ) ) { boolean ret = f . delete ( ) ; assert ret ; return f ; } } catch ( IOException e ) { // cant write to it - drop through
 } return getCacheFile ( fileLocation ) ; } }
Get a File if it exists. If not, get a File that can be written to.
If alwaysInCache, look only in the cache, otherwise, look in the "normal" location first,
then in the cache.
<p>

@param fileLocation  normal file location
@param alwaysInCache true if you want to look only in the cache
@return a File that either exists or is writeable.
Get a File if it exists . If not get a File that can be written to . If alwaysInCache look only in the cache otherwise look in the normal location first then in the cache . <p >