getting a file wthout extension

Hi to all!I want to get a file name without its extension, I have used getName() method of file class but it gives the extensions also,i want to eliminate the extension from the file name. so plzz help me,also plz write some code for itthanx
[262 byte] By [javaIndiaa] at [2007-11-27 2:27:17]
# 1
String name = yourFile.getName().substring(0, yourFile.getName().lastIndexOf('.'));hope that helps
java_2006a at 2007-7-12 2:37:48 > top of Java-index,Desktop,Core GUI APIs...
# 2
the getName() method has a String return type, so u can use the .split() method of The String class and split on the "." and u can also use a string tokenizer
bif_fa at 2007-7-12 2:37:48 > top of Java-index,Desktop,Core GUI APIs...
# 3

> String name = yourFile.getName().substring(0, yourFile.getName().lastIndexOf('.'));

You have to check if the name contains a dot first.

This piece of code is taken from here:

http://mindprod.com/jgloss/file.html

// getting the extension of a filename, (plain or including dirname)

// This code is much faster than any regex technique.

// filename without the extension

String choppedFilename;

// extension without the dot

String ext;

// where the last dot is. There may be more than one.

int dotPlace = filename.lastIndexOf ( '.' );

if ( dotPlace >= 0 )

{

// possibly empty

choppedFilename = filename.substring( 0, dotPlace );

// possibly empty

ext = filename.substring( dotPlace + 1 );

}

else

{

// was no extension

choppedFilename = filename;

ext = "";

}

Rodney_McKaya at 2007-7-12 2:37:48 > top of Java-index,Desktop,Core GUI APIs...
# 4
thanks 2 all who answered my query.
javaIndiaa at 2007-7-12 2:37:48 > top of Java-index,Desktop,Core GUI APIs...
# 5
thanks java_2006 the code helped me and i got it thanks again..
javaIndiaa at 2007-7-12 2:37:48 > top of Java-index,Desktop,Core GUI APIs...