Java example program to get extension


import java.util.*;

import java.lang.*;

public class GetFileExtension {

public static void main(String args[]) {

String fileName = args[0];

String fname=””;

String ext=””;

int mid= fileName.lastIndexOf(“.”);

fname=fileName.substring(0,mid);

ext=fileName.substring(mid+1,fileName.length());

System.out.println(“File name =”+fname);

System.out.println(“Extension =”+ext);

} }

 

//http://www.roseindia.net/java/java-get-example/get-file-extension.shtml

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s