Package java.io

Examples of java.io.File.canWrite()


                        if ( cleanupAttachment ) {
                         
                            for(int i=0; i<attachments.length; i++) {
                              File attachmentFile = new File(attachments[i]);
                              if ( attachmentFile.exists() && attachmentFile.canWrite() ) {
                                SOSFile.deleteFile( attachmentFile );
                              }
                            }
                        }
               
View Full Code Here


            try {
                eventFile = new File(this.getEventFilename());
                if (!eventFile.exists())  {
                    this.getLogger().info("event file does not exist: " + eventFile.getCanonicalPath());
                } else if (!eventFile.canWrite()) {
                    throw new Exception("required write permission for event file is missing: " + eventFile.getCanonicalPath());
                }
               
                File eventFileCopy = new File(this.getEventFilename() + "~");
                if (!eventFileCopy.exists()) {
View Full Code Here

                File eventFileCopy = new File(this.getEventFilename() + "~");
                if (!eventFileCopy.exists()) {
                    if (!eventFile.renameTo(eventFileCopy)) throw new Exception("could not create working copy of event file: renaming " + eventFile.getCanonicalPath() + " to " + eventFileCopy.getCanonicalPath());
                } else {
                    spooler_log.info("working copy of event file found - starting to process this file: " + eventFileCopy.getCanonicalPath());
                    if (!eventFileCopy.canWrite()) throw new Exception("required write permission for event file working copy is missing: " + eventFileCopy.getCanonicalPath());
                }           
               
                sos.hostware.File hwFile = new sos.hostware.File();

                if (eventFileCopy.getName().startsWith("-")) {
View Full Code Here

        if (dataDir.exists())
            throw new IOException("Target data path dir already exists: "
                    + dataDir.getAbsolutePath());
        if (!baseDir.isDirectory()) {
            final File parentDir = baseDir.getParentFile();
            if (!parentDir.canWrite())
                throw new IOException("Cannot create base RT directory '"
                        + baseDir.getAbsolutePath() + "'");
            if (!baseDir.mkdir())
                throw new IOException("Failed to create base RT directory '"
                        + baseDir.getAbsolutePath() + "'");
View Full Code Here

      String webappDir = ScopeApplicationAdapter.getInstance().webAppPath;
     
      String baseDir = webappDir + File.separatorChar + "upload" + File.separatorChar + "screens" + File.separatorChar;
     
      File f = new File(baseDir);
      if (!f.exists() || !f.canWrite()) {
        throw new Exception("Directory is Not writeable or does not exist "+baseDir);
      }
     
      String sessionDIR = baseDir + serverSharingSessionBean.getPublicSID() + File.separatorChar;
     
View Full Code Here

        }

        String mode = "rw";
        if (isReadonly && !isReadWrite && !isCreate && !isExclusive) {
            mode = "r";
        } else if (isReadWrite && !isExclusive && filePath.isFile() && !filePath.canWrite() && filePath.canRead()) {
            // force opening as read only.
            Set<SqlJetFileOpenPermission> ro = EnumSet.copyOf(permissions);
            ro.remove(SqlJetFileOpenPermission.READWRITE);
            ro.remove(SqlJetFileOpenPermission.CREATE);
            ro.add(SqlJetFileOpenPermission.READONLY);
View Full Code Here

            return false;
        }
      }


      if (!file.canWrite()) {
        MainWindow.message(Messages.getString("MainListener.fileWriteProtected"), //$NON-NLS-1$
            SWT.ICON_WARNING | SWT.OK);
        return false;
      } else {
        if (!saveas) {
View Full Code Here

          File installerdir = new File(working_dir);
         
          log.error("bb "+installerFile);
          log.error("bb "+working_dir+InstallationDocumentHandler.installFileName);
         
          boolean b = installerdir.canWrite();
         
          if (!b) {
            //File could not be created so throw an error
            ctx.put("error", "Could not Create File, Permission set? ");
            ctx.put("path", working_dir);
View Full Code Here

   * @return the path of the configuration file
   * @throws ConfigurationException
   */
  private File searchConfigurationFile(String searchPathIfFails, String configurationFileName) throws ConfigurationException {
    File retVal = new File(DEFAULT_CONFIG_DIRECTORY, configurationFileName);
    if (!(retVal.exists() && retVal.canWrite())) {
      File secondaryPath = new File(searchPathIfFails, configurationFileName);
      if (secondaryPath.exists()) {
        if (!secondaryPath.canWrite()) {
          File defaultPath = new File(DEFAULT_CONFIG_DIRECTORY);
          if (defaultPath.mkdirs()) {
View Full Code Here

  private File searchConfigurationFile(String searchPathIfFails, String configurationFileName) throws ConfigurationException {
    File retVal = new File(DEFAULT_CONFIG_DIRECTORY, configurationFileName);
    if (!(retVal.exists() && retVal.canWrite())) {
      File secondaryPath = new File(searchPathIfFails, configurationFileName);
      if (secondaryPath.exists()) {
        if (!secondaryPath.canWrite()) {
          File defaultPath = new File(DEFAULT_CONFIG_DIRECTORY);
          if (defaultPath.mkdirs()) {
            log.info("Copying " + configurationFileName + " from " + secondaryPath.getPath() + " to "
                + defaultPath.getPath());
            FileUtility.copyFile(secondaryPath, retVal);
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.