get FTP. ... _FILE_TYPE

@param file
@return type
518764
private int getType(Resource file) {
	if (transferMode == FTPConstant.TRANSFER_MODE_BINARY) return AFTPClient.FILE_TYPE_BINARY;
	else if (transferMode == FTPConstant.TRANSFER_MODE_ASCCI) return AFTPClient.FILE_TYPE_TEXT;
	else {
	    String ext = ResourceUtil.getExtension(file, null);
	    if (ext == null || ListUtil.listContainsNoCase(ASCIIExtensionList, ext, ";", true, false) == -1) return AFTPClient.FILE_TYPE_BINARY;
	    return AFTPClient.FILE_TYPE_TEXT;
	}
    }
426943
public function getMimeType($file){

        if(function_exists('finfo_open')) {
            $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
            $info = finfo_open($const);
            if($info && ($result = finfo_file($info,$file,$const)) !== false){
                finfo_close($info);
                return $result;
            }//if
        }//if

        if(function_exists('mime_content_type') && ($result = mime_content_type($file)) !== false) {
            return $result;
        }//if

    }
1056202
public static MediaType getFileMediaType(String fileName) {
        String extension = getUrlExtension(fileName);
        if (!MimeTypeMap.getSingleton().hasExtension(extension)) {
            return MediaType.APPLICATION_OCTET_STREAM;
        }

        String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
        try {
            return MediaType.parseMediaType(mimeType);
        } catch (Exception e) {
            return MediaType.APPLICATION_OCTET_STREAM;
        }
    }
915779
public static String fileAsString(File file) {
    try {
      return inputStreamAsString(new FileInputStream(file));
    } catch(FileNotFoundException e) {
      throw LOG.fileNotFoundException(file.getAbsolutePath(), e);
    }
  }
567251
@Override
  public InputStream getFileStream(String file) throws FileBasedHelperException {
    SftpGetMonitor monitor = new SftpGetMonitor();
    try {
      ChannelSftp channel = getSftpChannel();
      return new SftpFsFileInputStream(channel.get(file, monitor), channel);
    } catch (SftpException e) {
      throw new FileBasedHelperException("Cannot download file " + file + " due to " + e.getMessage(), e);
    }
  }
210823
private static String parseFilePath(String file)
    {
        final String excludePattern = "/META-INF/persistence.xml";
        file = file.substring(0, file.length() - excludePattern.length());

        // in case protocol is "file".
        file = file.endsWith("!") ? file.substring(0, file.length() - 1) : file;

        return file;
    }
270095
final public static function getFromFile($file)
    {
        if (!is_readable($file)) {
            throw new FileNotFoundException;
        }

        $fp    = fopen($file, 'r');
        $class = $namespace = $buffer = '';
        $i     = 0;
        while (!$class) {
            if (feof($fp)) {
                break;
            }

            $buffer .= fread($fp, 512);
            $tokens = @token_get_all($buffer);

            if (strpos($buffer, '{') === false) {
                continue;
            }
            $total = count($tokens);
            for (; $i < $total; $i++) {
                if ($tokens[$i][0] === T_NAMESPACE) {
                    for ($j = $i + 1; $j < count($tokens); $j++) {
                        if ($tokens[$j][0] === T_STRING) {
                            $namespace .= '\\' . $tokens[$j][1];
                        } else if ($tokens[$j] === '{' || $tokens[$j] === ';') {
                            break;
                        }
                    }
                } elseif ($tokens[$i][0] === T_CLASS) {
                    for ($j = $i + 1; $j < count($tokens); $j++) {
                        if ($tokens[$j] === '{') {
                            $class = $tokens[$i + 2][1];
                            break;
                        }
                    }
                    break;
                }
            }
        }
        fclose($fp);
        if (!$class) {
            throw new InvalidClassException;
        }
    
        return $namespace . '\\' . $class;
    }
1259335
public String getFileType() {
        if (fileTypeOrName != null && fileTypeOrName.contains(".")) {
            return FileUtils.getExtension(fileTypeOrName);
        } else {
            return fileTypeOrName;
        }
    }
464551
@SuppressWarnings("unchecked")
    public static <T> T load(File file) {
        try {
            FileInputStream fis = new FileInputStream(file);
            ObjectInputStream inStream = 
                new ObjectInputStream(new BufferedInputStream(fis));
            T object = (T) inStream.readObject();
            inStream.close();
            return object;
        } catch (IOException ioe) {
            throw new IOError(ioe);
        } catch (ClassNotFoundException cnfe) {
            throw new IOError(cnfe);
        }
    }
187459
def _get_content_type(self, file):
        
        if file.mimetype:
            return file.mimetype

        # get file extension
        _, extension = os.path.splitext(file.name)
        extension = extension.strip('.')

        # Make an educated guess about what the Content-Type should be.
        return media_types[extension] if extension in media_types else 'binary/octet-stream'
386607
protected function getFileType($file_url)
    {
        $file_info = (new Client())->head($file_url);
        $file_type = $file_info->getHeader('content-type');

        if (is_array($file_type)) {
            return reset($file_type);
        }

        return $file_type;
    }
813520
public static String getContentType(final String fileName) {

		if (Util.empty(fileName)) {
			return ConfigurationProperties.getDefaultMimeType();
		}

		String mimeType = null;

		if (fileName.lastIndexOf('.') > -1) {
			String suffix = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase();
			mimeType = ConfigurationProperties.getFileMimeTypeForExtension(suffix);
		}

		if (mimeType == null) {
			mimeType = URLConnection.guessContentTypeFromName(fileName);
			if (mimeType == null) {
				mimeType = ConfigurationProperties.getDefaultMimeType();
			}
		}

		return mimeType;
	}
1014310
protected static function getTypeFileExtList($file) {

		$info = pathinfo(strtolower($file));

		if(isset(self::$extensionToMime[$info['extension']])) {
			return self::$extensionToMime[$info['extension']];
		}
		else {
			return self::DEFAULT_MIME_TYPE;
		}

	}
374081
public static String file(File file) throws IOException {
        FileInputStream fi = null;
        try {
            fi = new FileInputStream(file);
            return stream(fi, file.length());
        } finally {
            if (fi != null) {
                try {
                    fi.close();
                } catch (Throwable t) {
                }
            }
        }

    }
262120
@Override
    protected FileType doGetType() throws Exception {
        // JDK BUG: 6192331
        // if (!file.exists())
        if (!file.exists() && file.length() < 1) {
            return FileType.IMAGINARY;
        }

        if (file.isDirectory()) {
            return FileType.FOLDER;
        }

        // In doubt, treat an existing file as file
        // if (file.isFile())
        // {
        return FileType.FILE;
        // }

        // throw new FileSystemException("vfs.provider.local/get-type.error", file);
    }
1352447
public static byte[] readFileAtOnce(final File file) throws IOException {
		final FileInputStream fIn = new FileInputStream(file);
		return readFileAtOnce(fIn);
	}
154091
public static InputStream fileAsStream(File file) {
    try {
      return new BufferedInputStream(new FileInputStream(file));
    } catch(FileNotFoundException e) {
      throw LOG.fileNotFoundException(file.getAbsolutePath(), e);
    }
  }