Here you can find the source of isTextFile(File file)
Parameter | Description |
---|---|
file | the file to check |
public static boolean isTextFile(File file)
//package com.java2s; /*//from w w w . j a va 2s .c o m * This software is distributed under the terms of the FSF * Gnu Lesser General Public License (see lgpl.txt). * * This program is distributed WITHOUT ANY WARRANTY. See the * GNU General Public License for more details. */ import java.io.File; import java.util.HashSet; import java.util.Set; public class Main { private static final Set<String> asciiFileExtensions = new HashSet<String>(); /** * Checks whether the file is a test file. This method should only be used * by Scooter's code generator. * * @param file the file to check * @return true if the file is text file. */ public static boolean isTextFile(File file) { boolean check = false; String fileName = file.getName(); int lastDot = fileName.lastIndexOf('.'); if (lastDot != -1) { String extension = fileName.substring(lastDot + 1); check = asciiFileExtensions.contains(extension); } return check; } }