Package java.io

Examples of java.io.File.canWrite()


    @Test
    public void testWriteAndReadSuccessfully() throws Exception  {
        File f = File.createTempFile("Test-ReleaseXmlSerializerTest", ".xml");
        String filename = f.getAbsolutePath();
        assertTrue(f.canRead());
        assertTrue(f.canWrite());
        //System.out.println("Persisting to file : "+filename);
        serializerUnderTest.write(channelBean, filename);
        ChannelXmlBean newBean = serializerUnderTest.readChannelBean(filename);
        assertEquals(channelBean, newBean);
       
View Full Code Here


      }

      private void writeTempFile(AtomicBoolean canUpdate, File dir) throws IOException {
        File tmpFile = File.createTempFile("permcheck", ".tmp", dir); //$NON-NLS-1$ //$NON-NLS-2$
        tmpFile.deleteOnExit();
        canUpdate.set(tmpFile.exists() && tmpFile.canWrite());
        tmpFile.delete();
      }
    });

    return canUpdate.get();
View Full Code Here

        + " cannot be serialized: " + e.getMessage());
      e.printStackTrace();
    } finally {
      ioutil.closeOutputStream(fos);
      ioutil.closeOutputStream(out);
      if (f.exists() && f.canWrite()) {
        f.delete();
      }
    }

  }
View Full Code Here

      File file = new File(getDBFilePath());
      if (!file.exists())
        throw new DiskFullException("Failed to create an empty database. This seems to indicate that the disk is full. Please free some space on the disk and restart RSSOwl.", e); //$NON-NLS-1$

      if (!file.canRead() || (!file.canWrite()))
        throw new InsufficientFilePermissionException("Current user has no permission to read and/or write file: " + file + ". Please make sure to start RSSOwl with sufficient permissions.", null); //$NON-NLS-1$ //$NON-NLS-2$

      BackupService backupService = createOnlineBackupService();
      if (backupService == null || e instanceof DatabaseFileLockedException)
        throw new PersistenceException(e);
View Full Code Here

    return status;
  }

  private void checkDirPermissions() {
    File dir = new File(Activator.getDefault().getStateLocation().toOSString());
    if (!dir.canRead() || (!dir.canWrite()))
      throw new InsufficientFilePermissionException("Current user has no permission to read from and/or write to directory: " + dir + ". Please make sure to start RSSOwl with sufficient permissions.", null); //$NON-NLS-1$ //$NON-NLS-2$
  }

  private IStatus restoreFromBackup(Configuration config, Throwable startupException, File currentDbCorruptedFile, BackupService... backupServices) {
    Assert.isNotNull(backupServices, "backupServices"); //$NON-NLS-1$
View Full Code Here

        String lyxpipeSetting = Globals.prefs.get("lyxpipe");
        if (!lyxpipeSetting.endsWith(".in"))
            lyxpipeSetting = lyxpipeSetting+".in";
        File lp = new File(lyxpipeSetting); // this needs to fixed because it gives "asdf" when going prefs.get("lyxpipe")
        if( !lp.exists() || !lp.canWrite()){
            // See if it helps to append ".in":
            lp = new File(lyxpipeSetting+".in");
            if( !lp.exists() || !lp.canWrite()){
                couldNotFindPipe = true;
                return;
View Full Code Here

            lyxpipeSetting = lyxpipeSetting+".in";
        File lp = new File(lyxpipeSetting); // this needs to fixed because it gives "asdf" when going prefs.get("lyxpipe")
        if( !lp.exists() || !lp.canWrite()){
            // See if it helps to append ".in":
            lp = new File(lyxpipeSetting+".in");
            if( !lp.exists() || !lp.canWrite()){
                couldNotFindPipe = true;
                return;
            }
        }
View Full Code Here

     try {
        URL fileURL = new URL(targetDir);

        File file = new File(fileURL.getFile());

        if(file.isDirectory() && file.canRead() && file.canWrite()) {
           dir = file;
        }
     }
     catch(Exception e) {
       // Otherwise, try to see inside the jboss directory hierarchy
View Full Code Here

    try {
       URL fileURL = new URL(baseDir);
       
       File file = new File(fileURL.getFile());
       
       if(file.isDirectory() && file.canRead() && file.canWrite()) {
          dir = file;
       }
    }
    catch(Exception e) {
     // Otherwise, try to make it inside the jboss directory hierarchy
View Full Code Here

      throws Exception
   {
      File file = new File(this.dataDir, filename);
     
      if (file.isFile()) {
         if (file.canRead() && file.canWrite()) {
            return file;  // everything fine
         }
         else {
            throw new Exception("file '" + filename + "' is not r/w"); // oops
         }
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.