Home Tutorialhelp Allcomments Java Java Get Example Get File Extension

 
 

Comments

 
User Comments for the tutorial:

Java example program to get extension



Advertisement
Comments

too long
String extension = filename.substring(filename.lastIndexOf(".")+1); 

Fails on some inputs
eg ".htaccess" or "noextension" Here's a fixed version: // default in case there's no extension: String baseName = fileName; String extension = ""; // split on position of dot in name int lastDotPos = fileName.lastIndexOf(".");  

Related Tutorial and Articles
General

Java example program to get extension
Java example program to get extension       java get extension To get the file name and file extension separately we can do the string manipulation on the file name. Suppose 

Java Technology Tutorials

Java filename without extension
Java filename without extension In his section, you will learn how to get the file name without extension. Description of code: In one of the previous... file without extension. You can see in the given example, we have created 

General

Java get Filename without Extension
Java get Filename without Extension   ... the filename without extension. For this, the file name or the directory name is being provided. file.getName()- This method returns the file name 

Java Tips and Examples

Java Display File-Extension
Java Display File-Extension   ... the file extension of the file. Here you will be asked to enter the file name and then you will get the extension of the file. Description of the code 

Java Tips and Examples

Java Change File-Extension
Java Change File-Extension     ... is to be changed and then you will get the file name with the changed extension... Enter file extension to change the file type: java FileExtension has 

General

Java Get Example
Java Get Example      .... Java Get Examples.. Get host name in Java: This example is going... practice   IP Address:  This Java Get IP Address example 

General

Java Get Example
Java Get Example      .... Java Get Examples.. Get host name in Java: This example... is method and how to use the get method in Java, this example is going 

Java Technology Tutorials

Java file get size
Java file get size In this section, you will learn how to get the size of a file. Description of code: You can see in the given example, we have created... args[]) { File file = new File("C:/java.txt"); long filesize = file.length 

Java Beginners

java get file permission
java get file permission  How to check the get file permission in Java 

Java Technology Tutorials

Java file get name
Java file get name In this section, you will learn how to get the name of the file. Description of code: You can see in the given example, we have created... get the name of any file. Output: File name is: out.txt 

Advertisements Advertisements
 

 

 

DMCA.com