Java Is Unix isUnixCompressFile(File file)

Here you can find the source of isUnixCompressFile(File file)

Description

Returns true if the input file is a .Z file.

License

Open Source License

Parameter

Parameter Description
file a parameter

Return

true if the file is a .Z file, false otherwise

Declaration

private static boolean isUnixCompressFile(File file) 

Method Source Code


//package com.java2s;

import java.io.File;

public class Main {
    /**/* w  ww .jav  a2  s .  com*/
     * suffix signifying a .Z file
     */
    private static final String z_suffix = ".Z";

    /**
     * Returns true if the input file is a .Z file. Determination is made by examining the file
     * suffix.
     * 
     * @param file
     * @return true if the file is a .Z file, false otherwise
     */
    private static boolean isUnixCompressFile(File file) {
        return hasCaseInsensitiveSuffix(file, z_suffix);
    }

    /**
     * Matches the file suffix to the input file in a case-insensitive manner
     * 
     * @param file
     * @param fileSuffix
     * @return true if the input file has the specified file suffix regardless of upper/lower case
     */
    private static boolean hasCaseInsensitiveSuffix(File file, String fileSuffix) {
        return file.getName().endsWith(fileSuffix.toLowerCase())
                || file.getName().endsWith(fileSuffix.toUpperCase());
    }
}

Related

  1. isOsUnix()
  2. isSystemUnix()
  3. isUnix()
  4. isUnix()
  5. isUnix()