Несколько типов в фильтре SaveFileDialog

Принимаемый ответ правильный, но он не говорит вам, как его использовать. Так вы используете функции indexOf и подстроки.

String filename = "abc.def.ghi";     // full file name
int iend = filename.indexOf("."); //this finds the first occurrence of "." 
//in string thus giving you the index of where it is in the string

// Now iend can be -1, if lets say the string had no "." at all in it i.e. no "." is found. 
//So check and account for it.

String subString;
if (iend != -1) 
{
    subString= filename.substring(0 , iend); //this will give abc
}
37
задан Eamonn McEvoy 14 April 2011 в 14:18
поделиться