0

I have a string named extractDb values can be

GDSHKG.db
GDSMNH.db
GDSTKY.db
GDSLDN.db

now i want to remove the .extension partof it

that is i want to see the result as

GDSHKG
GDSMNH
GDSTKY
GDSLDN

please advise how to achieve this in java

sss
  • 161
  • 1
  • 1
  • 13
  • Or [this](http://stackoverflow.com/questions/941272/how-do-i-trim-a-file-extension-from-a-string-in-java); or [this](http://stackoverflow.com/questions/7541550/remove-the-extension-of-a-file). – Tom Feb 24 '16 at 07:26
  • Your task looks like a simple search in string. Have a look into the developer's reference. – Alexander Dunaev Feb 24 '16 at 07:26

1 Answers1

2

Try to use substring like this:

    String myString = "GDSHKG.db";
    String newString = myString.substring(0, myString.indexOf("."));
     System.out.print(newString);

Output:

  GDSHKG
Abdelhak
  • 8,299
  • 4
  • 22
  • 36