Coders Packet

Get the file type from file name in Java

By Khushi Jain

In this module, we will learn how to get file type/extension from the file name in Java.

A file extension or file type denotes the format of the file.

For example, 

Let's say there is one file image.png, here, .png denotes the extension of the file.

This module will use the fileType() method that returns the file type to the Main() method. The Main() method then calls the fileType() and prints the required file type.

Also, if your file doesn't exist on your computer, then it will not print the file type.

Platform required: IntelliJ IDEA

Download Complete Code


No comments yet