Determine the file type

On this page

A file type is a standard way that information is encoded for storage in a computer file. For example, Microsoft Word (.docx) and Adobe PDF (.pdf) are two different file types.

Using GroupDocs.Viewer for Java, you can determine the file type using the file extension.

To determine the file type from the file extension, call the fromExtension() method of FileType.

The following code snippet shows how to determine a file type using the file extension:

import com.groupdocs.viewer.FileType;
// ...

String extension = ".docx";
FileType fileType = FileType.fromExtension(extension);

System.out.println("\nExtension " + extension + "; File type: " + fileType);

The following image shows a sample console output:

On this page