Java Path File Check nio isBinary(Path file)

Here you can find the source of isBinary(Path file)

Description

is Binary

License

Open Source License

Declaration

private static boolean isBinary(Path file) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2016-2019 Red Hat Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://from www.j av  a 2 s  . c om
 *     Red Hat Inc. - initial API and implementation
 *******************************************************************************/

import java.nio.file.Path;

public class Main {
    private static final String JAR_SUFFIX = ".jar";
    private static final String SOURCE_JAR_SUFFIX = "-sources.jar";

    private static boolean isBinary(Path file) {
        String fileName = file.getFileName().toString();
        return (fileName.endsWith(JAR_SUFFIX)
                //skip source jar files
                //more robust approach would be to check if jar contains .class files or not
                && !fileName.endsWith(SOURCE_JAR_SUFFIX));
    }
}

Related

  1. isAbsolute(String path)
  2. isAbsolutePath(String path)
  3. isAsciiText(Path p)
  4. isBallerinaProject(Path path)
  5. isContained(Path contained, Path container)
  6. isDirectory(Path fileOrDir, LinkOption... options)
  7. isDirectory(Path value)
  8. isDirectoryEmpty(Path dir)