Package java.io

Examples of java.io.File.canWrite()


      }
      if (!pp.isDirectory()) {
         log.severe(this.path + " is no directory, please specify another 'Persistence.Path' in xmlBlaster.properties");
         throw new XmlBlasterException(glob, ErrorCode.RESOURCE_CONFIGURATION, ME, this.path + " is no directory, please specify another 'Persistence.Path' in xmlBlaster.properties");
      }
      if (!pp.canWrite()) {
         log.severe("Sorry, no access permissions to " + this.path + ", please specify another 'Persistence.Path' in xmlBlaster.properties");
         throw new XmlBlasterException(glob, ErrorCode.RESOURCE_CONFIGURATION, ME, "Sorry, no access permissions to " + this.path + ", please specify another 'Persistence.Path' in xmlBlaster.properties");
      }
   }
View Full Code Here


    File file;
    int i, j;
    file = new File(fileName);
    try {
      PrintWriter out = new PrintWriter(new FileOutputStream(file));
      if (!file.canWrite())
        return false;// fail while opening the file
      for (i = 161; i < 255; i++)
        for (j = 161; j < 255; j++)
          out.println("" + i + j + "," + i + "," + j);
      out.close();
View Full Code Here

          // Check whether the file is readable.
          if (!file.canRead()) {
            mCrawlerJobProfiler.abortMeasuring();
            mLog.debug("File rights: canRead: " + file.canRead() +
                    " canExecute: " + file.canExecute() +
                    " canWrite: " + file.canWrite() + " exists: " + file.exists() +
                    " for url: " + url + ", canonical url: " + file.getCanonicalPath());
            logError("File is not readable: '" + url + "'", null, false);
            continue;
          } else if (file.isDirectory()) {
            // This IS a directory -> Add all child files as Jobs
View Full Code Here

  static void make(DiskCache2 dc, String filename) throws IOException {
    File want = dc.getCacheFile(filename);
    System.out.println("make=" + want.getPath() + "; exists = " + want.exists());
    if (!want.exists())
      want.createNewFile();
    System.out.println(" canRead= " + want.canRead() + " canWrite = " + want.canWrite() + " lastMod = " + new Date(want.lastModified()));

    String enc = EscapeStrings.urlEncode(filename);
    System.out.println(" original=" + EscapeStrings.urlDecode(enc));
    /* try {
      String enc = java.net.URLEncoder.encode(filename, "UTF8");
View Full Code Here

    File cacheIndex = null;
    if ( indexFile != null )
      cacheIndex = DiskCache.getFile( indexFile.getPath(), true);
    if ( cacheIndex != null && cacheIndex.exists())
    {
      if ( ! cacheIndex.canWrite())
        fail( "Cannot write/remove cache index file [" + cacheIndex.getPath() + "].");
      else if ( cacheIndex.exists() )
        cacheIndex.delete();
    }
    cacheIndex = null;
View Full Code Here

    cacheIndex = null;
    if ( indexFile != null )
      cacheIndex = DiskCache.getFile( GribIndexName.get(indexFile.getPath()), true);
    if ( cacheIndex != null && cacheIndex.exists())
    {
      if ( ! cacheIndex.canWrite())
        fail( "Cannot write/remove cache index file [" + cacheIndex.getPath() + "].");
      else if ( cacheIndex.exists() )
        cacheIndex.delete();
    }
  }
View Full Code Here

    File prevFile = new File(location);
    File tmpFile = new File(location+".tmp");
    if (tmpFile.exists()) tmpFile.delete();
    if (!prevFile.renameTo(tmpFile)) {
      System.out.println(prevFile.getPath()+ " prevFile.exists "+prevFile.exists()+" canRead = "+ prevFile.canRead());
      System.out.println(tmpFile.getPath()+" tmpFile.exists "+tmpFile.exists()+" canWrite "+ tmpFile.canWrite());
      throw new RuntimeException("Cant rename "+prevFile.getAbsolutePath()+" to "+ tmpFile.getAbsolutePath());
    }

    NetcdfFile oldFile = NetcdfFile.open(tmpFile.getPath());
View Full Code Here

      String currentDirectoryPath = (String) it.next();
      if (!excludedFromPrune.contains(currentDirectoryPath)) {
        File instance = new File(currentDirectoryPath);
        // If it has already been deleted, its OK
        if (instance.exists()) {
          if (!instance.canWrite() || instance.list().length > 0) {
            excludeDirectory(currentDirectoryPath);
          } else {
            if (!instance.delete()) {
              result.add(currentDirectoryPath);
            }
View Full Code Here

   *
   * @see entagged.tageditor.tools.renaming.data.stat.Prop#operate(entagged.tageditor.tools.renaming.data.AbstractFile)
   */
  public int operate(AbstractFile file) {
    File tmp = getFile(file.getPath());
    int result = tmp.exists() && !tmp.canWrite() ? 1 : 0;
    // if one can modify the given file and it is not a directory,
    // the directory must be tested, where the file resides
    if (result == 0 && !file.isDirectory()) {
      result = this.operate(file.getParent());
    }
View Full Code Here

      {
         throw new Exception("Can't find 'module.output'");
      }
      File dir = new File(moduleOutput);

      if (!dir.isDirectory() || !dir.canWrite())
      {
         throw new Exception(dir + " is either not a directory or not writable");
      }

      File file = new File(dir, SERIALIZED_CF_FILE_NAME);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.