Package java.io

Examples of java.io.File.canRead()


    // Make sure test DMSP file exists and such.
    File testFile = new File( testFilePath, testDataFileName );
    assertTrue( "Test file <" + testFile.getAbsolutePath() + "> does not exist.",
                testFile.exists() );
    assertTrue( "Test file <" + testFile.getAbsolutePath() + "> cannot be read.",
                testFile.canRead() );
    assertTrue( "Test file <" + testFile.getAbsolutePath() + "> is a directory.",
                ! testFile.isDirectory() );

    // Open test DMSP file as NetCDF file.
    try
View Full Code Here


   
    @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

      File file = getFileFromUrl(logger, url);
         if (file == null) {
           continue;
         }
        
      if (!file.isDirectory() && file.exists() && file.canRead())
      {
        ZipFile zipFile = null;
        try
        {
          zipFile = new ZipFile(file);
View Full Code Here

        String name = file.getName();
        if (!file.exists()) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return; // throw new IOException(file.getAbsolutePath());
        }
        if (!file.canRead()) {
            response.sendError(HttpServletResponse.SC_FORBIDDEN, "Can not read \"" + name + "\"!");
            return; // throw new IOException(file.getAbsolutePath());
        }

        //
View Full Code Here

            if (f.isDirectory()) {
                s_log.info(
                    "For driver '"+driverName+"', the JVM says the file is a directory: "+
                    fileNames[i]);
            }
            if (!f.canRead()) {
                s_log.info(
                    "For driver '"+driverName+"', the JVM says the file can't be read: "+
                    fileNames[i]);
            }
            urls[i] = f.toURI().toURL();
View Full Code Here

  protected void fileChanged()
  {
    Component componentToUse = _emptyPnl;

    File file = _chooser.getSelectedFile();
    if (file != null && file.isFile() && file.canRead())
    {
      String suffix = Utilities.getFileNameSuffix(file.getPath()).toLowerCase();
      if (suffix.equals("gif") || suffix.equals("jpg")
        || suffix.equals("jpeg") || suffix.equals("png"))
      {
View Full Code Here

  {
    ArrayList<String> flist = new ArrayList<String>();
   
    //*-- verify that the directory exists
    File d = new File(dir);
    if (!d.canRead() || !d.isDirectory()) return(flist);

    //*-- skip hidden directories
    //if (skipHidden && d.isHidden()) { return(flist); }
    if (skipHidden && d.getName().startsWith(".") ) return (flist);
 
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

  @RequestMapping(value = "/csvDownload", method = RequestMethod.GET)
  public void handleCsvDownload(@RequestParam("id") String id, HttpServletResponse response) throws IOException {
    try {
      Item item = service.getFile(id);
      File f = item.getFile();
      if (f == null || !f.canRead()) {
        response.sendError(404, "Geen document gevonden met id: " + id);
      } else {
        // Set response headers
        response.setContentType("text/csv");
        response.setContentLength((int) f.length());
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.