Package java.io

Examples of java.io.File.canWrite()


        // deleted if necessary.
        resumeMarker = 0;
        File localFile = new File(localPath);   
        if (localFile.exists()) {
            // if resuming, we must find the marker
            if (!localFile.canWrite())
                throw new FTPException(localPath
                        + " is readonly - cannot write");
            if (resume)
                resumeMarker = localFile.length();
        }
View Full Code Here


            if (!file.exists()) {
                if (!file.createNewFile()) {
                    return;
                }
            }
            if (file.canWrite()) {
                FileOutputStream output = new FileOutputStream(file);
                toolWindowManager.getPersistenceDelegate().save(output);

                output.close();
                //logger.info("Successfully saved layout.");
View Full Code Here

      //
      File f = new File(tmpDirPath);
      assertTrue(f.exists());
      assertTrue(f.isDirectory());
      assertTrue(f.canWrite());
      assertEquals(0, f.list().length);
   }
}
View Full Code Here

            throw new TeiidException(msg);
        }
       

        //test if file can be written to
        if (!tmpFile.canWrite()) {
            final String msg = CorePlugin.Util.getString("FileUtils.Unable_to_write_file_in", dirPath); //$NON-NLS-1$           
            throw new TeiidException(msg);
        }

        //test if file can be read
View Full Code Here

    if ( !file.exists()){
     
      throw( new IOException( "plist file '" + file + "' doesn't exist" ));
    }
   
    if ( !file.canWrite()){
     
      throw( new IOException( "plist file '" + file + "' is read only" ));
    }
  }
 
View Full Code Here

        getModel().setFileEnabled(!getModel().isFileEnabled());
      } else if (src == selectButton) {
        int result = chooser.showSaveDialog(getLogFrame());
        if (result != JFileChooser.APPROVE_OPTION) return;
        File file = chooser.getSelectedFile();
        if (file.exists() && (!file.canWrite() || file.isDirectory())) {
          JOptionPane.showMessageDialog(getLogFrame(),
            StringUtil.format(Strings.get("fileCannotWriteMessage"), file.getName()),
            Strings.get("fileCannotWriteTitle"),
            JOptionPane.OK_OPTION);
          return;
View Full Code Here

        else if (aFile.isFile())
          aFileType = "-";
        else
          aFileType = "?";
        String aFileRead = (aFile.canRead() ? "r" : "-");
        String aFileWrite = (aFile.canWrite() ? "w" : "-");
        String aFileExe = "-";
        if (canExecute != null)
          try {
            if (((Boolean) canExecute.invoke(aFile, Utils.EMPTY_OBJECTS)).booleanValue())
              aFileExe = "x";
View Full Code Here

    }

    private void testReadOnlyFiles(boolean setReadOnly) throws Exception {
        new File(System.getProperty("java.io.tmpdir")).mkdirs();
        File f = File.createTempFile("test", "temp");
        assertTrue(f.canWrite());
        f.setReadOnly();
        assertTrue(!f.canWrite());
        f.delete();

        f = File.createTempFile("test", "temp");
View Full Code Here

    private void testReadOnlyFiles(boolean setReadOnly) throws Exception {
        new File(System.getProperty("java.io.tmpdir")).mkdirs();
        File f = File.createTempFile("test", "temp");
        assertTrue(f.canWrite());
        f.setReadOnly();
        assertTrue(!f.canWrite());
        f.delete();

        f = File.createTempFile("test", "temp");
        RandomAccessFile r = new RandomAccessFile(f, "rw");
        r.write(1);
View Full Code Here

        f = File.createTempFile("test", "temp");
        RandomAccessFile r = new RandomAccessFile(f, "rw");
        r.write(1);
        f.setReadOnly();
        r.close();
        assertTrue(!f.canWrite());
        f.delete();

        deleteDb("readonly");
        Connection conn = getConnection("readonly");
        Statement stat = conn.createStatement();
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.