Java Is Readable File isReadable(String filename)

Here you can find the source of isReadable(String filename)

Description

Determine if the given filename exists and is readable.

License

Apache License

Parameter

Parameter Description
filename The file to check.

Return

true if the file exists and is readable. If the filename is null, then false is returned.

Declaration

public static boolean isReadable(String filename) 

Method Source Code


//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.io.File;

public class Main {
    /**//from ww w  .  j a v a 2 s  .  c om
     * Determine if the given filename exists and is readable.
     * @param filename The file to check.
     * @return true if the file exists and is readable. If the filename is null,
     * then false is returned.
     */
    public static boolean isReadable(String filename) {
        if (filename == null) {
            return false;
        }

        File file = new File(filename);
        return file.exists() && file.canRead();
    }
}

Related

  1. isReachable(String internetProtocolAddress)
  2. isReadable(File arcFile)
  3. isReadableFile(File f)
  4. isReadableFile(File file)
  5. isReadableFile(File file)
  6. isReadableFile(File file)