Java File Extension8 May 2025 | 3 min read The File extension is the suffix attached to a computer file. It can be identified easily as it directly appears in the file name after a period (.) For example, consider a file name Demo.java, here the file name is Demo and .java is the file extension that represents the type of the file. In this section, we will learn how to get extension of file through a Java program. Java File Class
Getting File ExtensionThere are two ways to get file extension in Java: The following program uses the File class to identify the extension of the specified file that we give as input. FileTypeDemo.java Output: ![]() In the above Java program,
Using Apache Commons IOApache Commons IO is the component of Apache derived from Java API. They provide multiple methods to perform different operations on files without creating an object of the file. In the following program we have used the FilenameUtils.getExtension() method to get the file extension. GetFileExtensionApache,java Output: Extension: txt In the above Java program, getExtension() method of the FilenameUtils class is used to get the file extension without creating the file object. |
Java Pass by Value
People usually take the pass by value and pass by reference terms together. It is really confusing and overhear questions in interviews, Is java pass by value or passes by reference, or both? So the answer to this question is Java is strictly pass by value....
3 min read
Types of Errors in Java
Java is one of the most widely used programming languages in the world, and is known for its reliability and portability. However, like any other programming language, Java is not without its challenges. Programmers, especially beginners, often make mistakes in the development process. These errors can...
5 min read
EnumMap in Java
In the world of Java programming, data structures play a critical position in dealing with and organizing records correctly. One such facts structure that proves to be extremely beneficial is the EnumMap. EnumMaps are specialized Map implementations in Java designed to work with Enum keys. In...
8 min read
How to Create Singleton Class in Java
In Java, Singleton class is a class that controls the object creation. It means the singleton class allows us to create a single object of the class, at a time. It is usually used to control access to resources, such as database connections or sockets. It...
3 min read
Java OCR
What is Tesseract OCR? The Tesseract OCR is an optical character reading engine developed by HP laboratories in 1985 and launched in 2005. Since 2006 it has been developed by Google. Tesseract has Unicode Support (UTF-8) and can detect more than 100 languages "out of the box"...
6 min read
Sort An Array According To The Set Bits Count in Java
An array containing natural numbers is given to us. Our task is to sort the input array as per the number of set bits in the binary representation of the elements present in the input array. That is, a number that has a greater number of...
9 min read
AWS Lambda in Java
AWS lambda is a "service less" compute service that the developers do not have to worry about which AWS resources to launch or how they will manage them. They just put the code on Lambda, and it runs. However, a lambda can only use to execute...
21 min read
extends Keyword in Java
Java extends keywords enable classes to inherit properties and behaviours from superclasses. It establishes an inheritance relationship between two classes (subclass and superclass). A subclass inherits all non-private characteristics and procedures from its superclass, which serves as both parent and base class. Syntax: class Subclass extends Superclass...
5 min read
Hollow Rectangle or Square Star Patterns in Java
In programming, printing star patterns of different shapes and types can be an interesting exercise. The practice of printing these types of patterns enhances knowledge of nested loops. So, in this section, we are going to understand how to print hollow rectangle or square star patterns...
7 min read
Difference Between C, C++, and Java
C Language C is a general-purpose, structured, procedural, and high-level programming language developed by Dennis MacAlistair Ritchie in 1972 at Bell Laboratories. The successor of the C language was CPL (Combined Programming Language). It is mainly used for system programming, such as to develop the operating...
5 min read
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India
