List of utility methods to do Is Text File
boolean | isText(File file) is Text try { byte[] buf = new byte[512]; FileInputStream in = new FileInputStream(file); int len = in.read(buf); in.close(); if (len == 0) return true; int numNonTextChars = 0; ... |
boolean | isText(File file) Checks for text file. try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) { int count = 0; int val = bufferedInputStream.read(); while ((count < MAX_NB_BINARY_BYTES) && (val >= 0)) { if (val == 0) { return false; count++; ... |
boolean | isTextFile(File f) is Text File if (!f.isFile()) { return false; final String name = f.getName(); final int lastDotIdx = name.lastIndexOf('.'); if (lastDotIdx < 0) { return false; final String extension = name.substring(lastDotIdx + 1); switch (extension) { case "buildinfo": case "html": case "css": case "js": case "svg": case "txt": case "xml": return true; case "map": return name.endsWith(".css.map") || name.endsWith(".js.map"); return false; |
boolean | isTextFile(File f, int length) is Text File if (!f.isFile()) return false; BufferedReader br = null; try { FileReader fr = new FileReader(f); br = new BufferedReader(fr); int l = (int) f.length(); if (l > length) ... |
boolean | isTextFile(File file) Checks whether the file is a test 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; ... |
boolean | isTextFile(File file) Checks a File and tries to figure if the file is a text or a binary file. Keep in mind that binary files are those that contains at least one non-printable character. return isTextFile(file, 1024);
|